[llvm] [RISCV] Don't commute with shift if it would break sh{1,2,3}add pattern (PR #119527)

Yi Kong via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 7 00:29:22 PST 2025


kongy wrote:

This change caused a regression when building clang_rt:

```
Stack dump:
0.	Program arguments: /tmpfs/src/git/out/stage2-install/bin/clang --target=riscv64-linux-android35 --sysroot=/tmpfs/src/git/out/sysroots/ndk/riscv64 -DVISIBILITY_HIDDEN -ffile-prefix-map=/tmpfs/src/git/= --target=riscv64-linux-android35 -ffunction-sections -fdata-sections -isystem /tmpfs/src/git/out/sysroots/ndk/riscv64/usr/include/riscv64-linux-android -D_LIBCPP_AVAILABILITY_HAS_NO_VERBOSE_ABORT=1 --sysroot=/tmpfs/src/git/out/sysroots/ndk/riscv64 -O3 -DNDEBUG -fPIC -fno-lto -std=c11 -fPIC -fno-builtin -fvisibility=hidden -fomit-frame-pointer -DCOMPILER_RT_HAS_FLOAT16 -MD -MT CMakeFiles/clang_rt.builtins-riscv64.dir/truncsfhf2.c.o -MF CMakeFiles/clang_rt.builtins-riscv64.dir/truncsfhf2.c.o.d -o CMakeFiles/clang_rt.builtins-riscv64.dir/truncsfhf2.c.o -c /tmpfs/src/git/out/llvm-project/compiler-rt/lib/builtins/truncsfhf2.c
1.	<eof> parser at end of file
2.	Code generation
3.	Running pass 'Function Pass Manager' on module '/tmpfs/src/git/out/llvm-project/compiler-rt/lib/builtins/truncsfhf2.c'.
4.	Running pass 'RISC-V DAG->DAG Pattern Instruction Selection' on function '@__truncsfhf2'
 #0 0x000059e73a5b34e8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/tmpfs/src/git/out/stage2-install/bin/clang+0x393d4e8)
 #1 0x000059e73a5b122e llvm::sys::RunSignalHandlers() (/tmpfs/src/git/out/stage2-install/bin/clang+0x393b22e)
 #2 0x000059e73a5b298f llvm::sys::CleanupOnSignal(unsigned long) (/tmpfs/src/git/out/stage2-install/bin/clang+0x393c98f)
 #3 0x000059e73a5408f9 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #4 0x000071314ff40520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #5 0x000059e7396d0828 llvm::RISCVTargetLowering::isDesirableToCommuteWithShift(llvm::SDNode const*, llvm::CombineLevel) const RISCVISelLowering.cpp:0:0
 #6 0x000059e73b2e2f3c (anonymous namespace)::DAGCombiner::visitSHL(llvm::SDNode*) DAGCombiner.cpp:0:0
 #7 0x000059e73b2ce5f0 (anonymous namespace)::DAGCombiner::combine(llvm::SDNode*) DAGCombiner.cpp:0:0
 #8 0x000059e73b2cd41d llvm::SelectionDAG::Combine(llvm::CombineLevel, llvm::AAResults*, llvm::CodeGenOptLevel) (/tmpfs/src/git/out/stage2-install/bin/clang+0x465741d)
 #9 0x000059e73b4402ff llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/tmpfs/src/git/out/stage2-install/bin/clang+0x47ca2ff)
#10 0x000059e73b43ff31 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/tmpfs/src/git/out/stage2-install/bin/clang+0x47c9f31)
#11 0x000059e73b43dca2 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/tmpfs/src/git/out/stage2-install/bin/clang+0x47c7ca2)
#12 0x000059e73b43c5ca llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&) (/tmpfs/src/git/out/stage2-install/bin/clang+0x47c65ca)
#13 0x000059e739e21f9d llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/tmpfs/src/git/out/stage2-install/bin/clang+0x31abf9d)
```

Let me know if you need more information for debugging

https://github.com/llvm/llvm-project/pull/119527


More information about the llvm-commits mailing list