llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.04k stars 11.98k forks source link

Assertion `(CCVal != ISD::SETUGT || Imm != -1) && "Missing canonicalization"` failed #64503

Closed chfast closed 1 year ago

chfast commented 1 year ago
llc: /root/llvm-project/llvm/lib/Target/RISCV/RISCVISelLowering.cpp:5577: virtual llvm::SDValue llvm::RISCVTargetLowering::LowerOperation(llvm::SDValue, llvm::SelectionDAG&) const: Assertion `(CCVal != ISD::SETUGT || Imm != -1) && "Missing canonicalization"' 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 -x86-asm-syntax=intel <source>
1.  Running pass 'Function Pass Manager' on module '<source>'.
2.  Running pass 'RISC-V DAG->DAG Pattern Instruction Selection' on function '@f'
 #0 0x0000000003397178 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x3397178)
 #1 0x0000000003394a6c SignalHandler(int) Signals.cpp:0:0
 #2 0x00007f858563a420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #3 0x00007f85850fd00b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
 #4 0x00007f85850dc859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
 #5 0x00007f85850dc729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
 #6 0x00007f85850edfd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
 #7 0x00000000018b4067 llvm::RISCVTargetLowering::LowerOperation(llvm::SDValue, llvm::SelectionDAG&) const (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x18b4067)
 #8 0x00000000030603f9 (anonymous namespace)::SelectionDAGLegalize::LegalizeOp(llvm::SDNode*) (.part.0) LegalizeDAG.cpp:0:0
 #9 0x000000000306433c llvm::SelectionDAG::Legalize() (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x306433c)
#10 0x000000000316b34d llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x316b34d)
#11 0x000000000316ec88 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x316ec88)
#12 0x0000000003170982 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (.part.0) SelectionDAGISel.cpp:0:0
#13 0x0000000002681449 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#14 0x0000000002bf7f99 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2bf7f99)
#15 0x0000000002bf81d1 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2bf81d1)
#16 0x0000000002bf89f2 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2bf89f2)
#17 0x000000000075e1c2 compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0

test case 1 (https://godbolt.org/z/sE4oMWo1o)

target triple = "riscv32"

define i1 @f(i64 %LGV1) {
  %B1 = xor i64 %LGV1, %LGV1
  %B2 = srem i64 1, %B1
  %B5 = lshr i64 1, %B2
  %C4 = icmp ule i64 %LGV1, %B5
  ret i1 %C4
}

test case 2 (https://godbolt.org/z/frx45zshE)

target triple = "riscv32"

define i64 @f(ptr %A, i64 %0) {
  store i64 poison, ptr %A, align 4
  %LGV1 = load i64, ptr %A, align 4
  %B1 = ashr i64 1, %LGV1
  %C = icmp sle i64 %0, %B1
  store i1 %C, ptr null, align 1
  ret i64 %LGV1
}
llvmbot commented 1 year ago

@llvm/issue-subscribers-backend-risc-v

topperc commented 1 year ago

/cherry-pick 7cc615413fd7c93421052a193bc3e114465747c9

llvmbot commented 1 year ago

/branch llvm/llvm-project-release-prs/issue64503

llvmbot commented 1 year ago

/pull-request llvm/llvm-project-release-prs#540