[llvm] [RISCV] Add isel optimization for (and (sra y, c2), c1) to recover regression from #101751. (PR #104114)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 23 08:57:54 PDT 2024
dtcxzyw wrote:
Reproducer:
```
; bin/llc -mtriple=riscv64 -mattr=+zba reduced.ll -o -
define i64 @utrace_vformat_74(i64 %x, i64 %p) {
entry:
%shr = ashr i64 %x, %x
%and = and i64 %shr, 15
%add = add i64 %p, %and
ret i64 %add
}
```
```
llc: /home/dtcxzyw/WorkSpace/Projects/compilers/llvm-project/llvm/include/llvm/Support/Casting.h:566: decltype(auto) llvm::cast(const From&) [with To = ConstantSDNode; From = SDValue]: Assertion `isa<To>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: bin/llc -mtriple=riscv64 -mattr=+zba reduced.ll
1. Running pass 'Function Pass Manager' on module 'reduced.ll'.
2. Running pass 'RISC-V DAG->DAG Pattern Instruction Selection' on function '@utrace_vformat_74'
#0 0x000072d578e12be2 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMSupport.so.20.0git+0x212be2)
#1 0x000072d578e0faaf llvm::sys::RunSignalHandlers() (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMSupport.so.20.0git+0x20faaf)
#2 0x000072d578e0fbf5 SignalHandler(int) Signals.cpp:0:0
#3 0x000072d578442520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x000072d5784969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
#5 0x000072d5784969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10
#6 0x000072d5784969fc pthread_kill ./nptl/pthread_kill.c:89:10
#7 0x000072d578442476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
#8 0x000072d5784287f3 abort ./stdlib/abort.c:81:7
#9 0x000072d57842871b _nl_load_domain ./intl/loadmsgcat.c:1177:9
#10 0x000072d578439e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#11 0x000072d57f0d2045 llvm::SDNode::getConstantOperandVal(unsigned int) const (.constprop.0.isra.0) RISCVISelDAGToDAG.cpp:0:0
#12 0x000072d57f0dda36 llvm::RISCVDAGToDAGISel::selectSHXADDOp(llvm::SDValue, unsigned int, llvm::SDValue&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMRISCVCodeGen.so.20.0git+0xdda36)
#13 0x000072d57bdd305d llvm::SelectionDAGISel::SelectCodeCommon(llvm::SDNode*, unsigned char const*, unsigned int) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMSelectionDAG.so.20.0git+0x3d305d)
#14 0x000072d57f0ec827 llvm::RISCVDAGToDAGISel::Select(llvm::SDNode*) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMRISCVCodeGen.so.20.0git+0xec827)
#15 0x000072d57bdbdf63 llvm::SelectionDAGISel::DoInstructionSelection() (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMSelectionDAG.so.20.0git+0x3bdf63)
#16 0x000072d57bdcbcd3 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMSelectionDAG.so.20.0git+0x3cbcd3)
#17 0x000072d57bdcec8f llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMSelectionDAG.so.20.0git+0x3cec8f)
#18 0x000072d57bdd0239 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMSelectionDAG.so.20.0git+0x3d0239)
#19 0x000072d57bdc488a llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMSelectionDAG.so.20.0git+0x3c488a)
#20 0x000072d57b2407e6 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMCodeGen.so.20.0git+0x4407e6)
#21 0x000072d5792fe958 llvm::FPPassManager::runOnFunction(llvm::Function&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMCore.so.20.0git+0x2fe958)
#22 0x000072d5792fef61 llvm::FPPassManager::runOnModule(llvm::Module&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMCore.so.20.0git+0x2fef61)
#23 0x000072d5792fdc37 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/home/dtcxzyw/WorkSpace/Projects/compilers/LLVM/llvm-build/bin/../lib/libLLVMCore.so.20.0git+0x2fdc37)
#24 0x000055cf35f7252e compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
#25 0x000055cf35f65e55 main (bin/llc+0x13e55)
#26 0x000072d578429d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#27 0x000072d578429e40 call_init ./csu/../csu/libc-start.c:128:20
#28 0x000072d578429e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#29 0x000055cf35f66cb5 _start (bin/llc+0x14cb5)
Aborted (core dumped)
```
https://github.com/llvm/llvm-project/pull/104114
More information about the llvm-commits
mailing list