Skip to content

assertion failing in multiple backends N->getValueType(0) == RV.getValueType() && N->getNumValues() == 1 && "Type mismatch" #84831

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
regehr opened this issue Mar 11, 2024 · 4 comments · Fixed by #84888
Assignees
Labels
crash-on-valid llvm:SelectionDAG SelectionDAGISel as well

Comments

@regehr
Copy link
Contributor

regehr commented Mar 11, 2024

llc is asserting out for me on this code when targeting either x86-64 or AArch64

define i1 @f(i64 %0) {
  %2 = icmp ult i64 0, %0
  %3 = add i64 0, 1
  %4 = icmp ult i64 %3, 0
  %5 = zext i1 %2 to i64
  %6 = add i64 %3, %5
  %7 = icmp ult i64 %6, %3
  %8 = zext i1 %4 to i63
  %9 = zext i1 %7 to i63
  %new0 = or i63 %8, %9
  %last = trunc i63 %new0 to i1
  ret i1 %last
}
@llvmbot
Copy link
Member

llvmbot commented Mar 11, 2024

@llvm/issue-subscribers-backend-aarch64

Author: John Regehr (regehr)

`llc` is asserting out for me on this code when targeting either x86-64 or AArch64 ```llvm define i1 @f(i64 %0) { %2 = icmp ult i64 0, %0 %3 = add i64 0, 1 %4 = icmp ult i64 %3, 0 %5 = zext i1 %2 to i64 %6 = add i64 %3, %5 %7 = icmp ult i64 %6, %3 %8 = zext i1 %4 to i63 %9 = zext i1 %7 to i63 %new0 = or i63 %8, %9 %last = trunc i63 %new0 to i1 ret i1 %last } ```

@llvmbot
Copy link
Member

llvmbot commented Mar 11, 2024

@llvm/issue-subscribers-backend-x86

Author: John Regehr (regehr)

`llc` is asserting out for me on this code when targeting either x86-64 or AArch64 ```llvm define i1 @f(i64 %0) { %2 = icmp ult i64 0, %0 %3 = add i64 0, 1 %4 = icmp ult i64 %3, 0 %5 = zext i1 %2 to i64 %6 = add i64 %3, %5 %7 = icmp ult i64 %6, %3 %8 = zext i1 %4 to i63 %9 = zext i1 %7 to i63 %new0 = or i63 %8, %9 %last = trunc i63 %new0 to i1 ret i1 %last } ```

@RKSimon
Copy link
Collaborator

RKSimon commented Mar 11, 2024

https://clang.godbolt.org/z/76GE87h8z

Combining: t12: i63 = or t10, t11
Creating new node: t20: i64,i1 = uaddo_carry Constant:i64<0>, Constant:i64<1>, t5
 ... into: t20: i64,i1 = uaddo_carry Constant:i64<0>, Constant:i64<1>, t5
llc: /root/llvm-project/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1761: void {anonymous}::DAGCombiner::Run(llvm::CombineLevel): Assertion `N->getValueType(0) == RV.getValueType() && N->getNumValues() == 1 && "Type mismatch"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/llc -o /app/output.s -debug <source>
1.	Running pass 'Function Pass Manager' on module '<source>'.
2.	Running pass 'X86 DAG->DAG Instruction Selection' on function '@f'
 #0 0x00000000038fcf98 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x38fcf98)
 #1 0x00000000038fa6ec SignalHandler(int) Signals.cpp:0:0
 #2 0x00007f7d31e42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #3 0x00007f7d31e969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #4 0x00007f7d31e42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #5 0x00007f7d31e287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #6 0x00007f7d31e2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #7 0x00007f7d31e39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
 #8 0x000000000356d1a7 (anonymous namespace)::DAGCombiner::Run(llvm::CombineLevel) DAGCombiner.cpp:0:0
 #9 0x000000000356e0ba llvm::SelectionDAG::Combine(llvm::CombineLevel, llvm::AAResults*, llvm::CodeGenOptLevel) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x356e0ba)
#10 0x00000000036c21d2 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x36c21d2)
#11 0x00000000036c5d15 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x36c5d15)
#12 0x00000000036c7787 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (.part.0) SelectionDAGISel.cpp:0:0
#13 0x0000000001dc91ac (anonymous namespace)::X86DAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) X86ISelDAGToDAG.cpp:0:0
#14 0x0000000002921a31 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#15 0x0000000002edc129 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2edc129)
#16 0x0000000002edc361 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2edc361)
#17 0x0000000002edcbb2 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2edcbb2)
#18 0x000000000080e09c compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
#19 0x0000000000720696 main (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x720696)
#20 0x00007f7d31e29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#21 0x00007f7d31e29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#22 0x0000000000804bbe _start (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x804bbe)
Program terminated with signal: SIGSEGV

@XChy
Copy link
Member

XChy commented Mar 12, 2024

@XChy XChy self-assigned this Mar 12, 2024
arsenm pushed a commit that referenced this issue Mar 22, 2024
…rryDiamond` (#84888)

Fixes #84831
When matching carry pattern with `getAsCarry`, it may produce different
type of carryout. This patch checks such case and does early exit.

I'm new to DAG, any suggestion is appreciated.
chencha3 pushed a commit to chencha3/llvm-project that referenced this issue Mar 23, 2024
…rryDiamond` (llvm#84888)

Fixes llvm#84831
When matching carry pattern with `getAsCarry`, it may produce different
type of carryout. This patch checks such case and does early exit.

I'm new to DAG, any suggestion is appreciated.
AZero13 pushed a commit to AZero13/llvm-project that referenced this issue Mar 26, 2024
…rryDiamond` (llvm#84888)

Fixes llvm#84831
When matching carry pattern with `getAsCarry`, it may produce different
type of carryout. This patch checks such case and does early exit.

I'm new to DAG, any suggestion is appreciated.

(cherry picked from commit cb4453d)
tstellar pushed a commit to AZero13/llvm-project that referenced this issue Apr 16, 2024
…rryDiamond` (llvm#84888)

Fixes llvm#84831
When matching carry pattern with `getAsCarry`, it may produce different
type of carryout. This patch checks such case and does early exit.

I'm new to DAG, any suggestion is appreciated.

(cherry picked from commit cb4453d)
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
crash-on-valid llvm:SelectionDAG SelectionDAGISel as well
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants