[llvm] [GlobalISel] Combine (X == 0) & (Y == 0) -> (X | Y) == 0 (PR #71949)

Dávid Ferenc Szabó via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 10 07:12:06 PST 2023


dfszabo wrote:

Uploading this version for debug purposes. The original one is here: https://github.com/llvm/llvm-project/pull/69017.

Notes for now I used i32 as type for ordst, but it should be the type of the G_ICMP's source.

Findings:
With cpp code:
`CSEInfo::Found Instr %2:_(s32) = G_CONSTANT i32 0
Creating: G_OR

CSEInfo::Recording new MI G_OR
Creating: G_OR

CSEInfo::Recording new MI G_OR
Creating: G_ICMP

Creating: G_ICMP

Erasing: %5:_(s1) = G_OR %3:_, %4:_

927: GIR_Done
Created: %8:_(s32) = G_OR %0:_, %1:_
Created: %5:_(s1) = G_ICMP intpred(ne), %8:_(s32), %2:_

Try combining %5:_(s1) = G_ICMP intpred(ne), %8:_(s32), %2:_`

With this version:
`1035: TempRegs[0] = GIR_MakeTempReg(0)
Creating: G_OR

CSEInfo::Recording new MI G_OR
1038: GIR_BuildMI(OutMIs[0], 57)
1042: GIR_AddTempRegister(OutMIs[0], TempRegisters[0], 0)
1046: GIR_Copy(OutMIs[0], MIs[1], 2)
1050: GIR_Copy(OutMIs[0], MIs[2], 2)
1052: GIR_EraseFromParent(MIs[0])
Erasing: %5:_(s1) = G_OR %3:_, %4:_

Erasing: %5:_(s1) = G_OR %3:_, %4:_

PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: /home/david/work/llvm-community/build/bin/llc -mtriple=aarch64-- -global-isel -debug
1.	Running pass 'Function Pass Manager' on module '<stdin>'.
2.	Running pass 'AArch64PreLegalizerCombiner' on function '@true_or2'
 #0 0x00007f7d339477b2 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/david/work/llvm-community/llvm-project/llvm/lib/Support/Unix/Signals.inc:723:22
 #1 0x00007f7d33947bc3 PrintStackTraceSignalHandler(void*) /home/david/work/llvm-community/llvm-project/llvm/lib/Support/Unix/Signals.inc:798:1
 #2 0x00007f7d33945146 llvm::sys::RunSignalHandlers() /home/david/work/llvm-community/llvm-project/llvm/lib/Support/Signals.cpp:105:20
 #3 0x00007f7d3394706c SignalHandler(int) /home/david/work/llvm-community/llvm-project/llvm/lib/Support/Unix/Signals.inc:413:1
 #4 0x00007f7d3312b0c0 (/lib/x86_64-linux-gnu/libc.so.6+0x430c0)
 #5 0x00007f7d3ad7d65a llvm::MachineBasicBlock::getParent() /home/david/work/llvm-community/llvm-project/llvm/include/llvm/CodeGen/MachineBasicBlock.h:275:41
 #6 0x00007f7d3adcb1cc llvm::BuildMI(llvm::MachineBasicBlock&, llvm::MachineInstrBundleIterator<llvm::MachineInstr, false>, llvm::MIMetadata const&, llvm::MCInstrDesc const&) /home/david/work/llvm-community/llvm-project/llvm/include/llvm/CodeGen/MachineInstrBuilder.h:435:38
 #7 0x00007f7d3adcb3fe llvm::BuildMI(llvm::MachineBasicBlock&, llvm::MachineInstr&, llvm::MIMetadata const&, llvm::MCInstrDesc const&) /home/david/work/llvm-community/llvm-project/llvm/include/llvm/CodeGen/MachineInstrBuilder.h:459:1
 #8 0x00007f7d3adcb448 llvm::BuildMI(llvm::MachineBasicBlock&, llvm::MachineInstr*, llvm::MIMetadata const&, llvm::MCInstrDesc const&) /home/david/work/llvm-community/llvm-project/llvm/include/llvm/CodeGen/MachineInstrBuilder.h:465:1
 #9 0x00007f7d3ae2a39d bool llvm::GIMatchTableExecutor::executeMatchTable<(anonymous namespace)::AArch64PreLegalizerCombinerImpl const, llvm::Bitset<0u>, std::optional<llvm::SmallVector<std::function<void (llvm::MachineInstrBuilder&)>, 4u>> ((anonymous namespace)::AArch64PreLegalizerCombinerImpl::*)(llvm::MachineOperand&) const, void ((anonymous namespace)::AArch64PreLegalizerCombinerImpl::*)(llvm::MachineInstrBuilder&, llvm::MachineInstr const&, int) const>((anonymous namespace)::AArch64PreLegalizerCombinerImpl const&, llvm::SmallVector<llvm::MachineInstrBuilder, 4u>&, llvm::GIMatchTableExecutor::MatcherState&, llvm::GIMatchTableExecutor::ExecInfoTy<llvm::Bitset<0u>, std::optional<llvm::SmallVector<std::function<void (llvm::MachineInstrBuilder&)>, 4u>> ((anonymous namespace)::AArch64PreLegalizerCombinerImpl::*)(llvm::MachineOperand&) const, void ((anonymous namespace)::AArch64PreLegalizerCombinerImpl::*)(llvm::MachineInstrBuilder&, llvm::MachineInstr const&, int) const> const&, long const*, llvm::TargetInstrInfo const&, llvm::MachineRegisterInfo&, llvm::TargetRegisterInfo const&, llvm::RegisterBankInfo const&, llvm::Bitset<0u> const&, llvm::CodeGenCoverage*, llvm::GISelChangeObserver*) const /home/david/work/llvm-community/llvm-project/llvm/include/llvm/CodeGen/GlobalISel/GIMatchTableExecutorImpl.h:917:34
#10 0x00007f7d3ae226eb (anonymous namespace)::AArch64PreLegalizerCombinerImpl::tryCombineAllImpl(llvm::MachineInstr&) const /home/david/work/llvm-community/build/lib/Target/AArch64/AArch64GenPreLegalizeGICombiner.inc:1699:24
#11 0x00007f7d3ae23a13 (anonymous namespace)::AArch64PreLegalizerCombinerImpl::tryCombineAll(llvm::MachineInstr&) const /home/david/work/llvm-community/llvm-project/llvm/lib/Target/AArch64/GISel/AArch64PreLegalizerCombiner.cpp:392:3
#12 0x00007f7d32bdcbd8 llvm::Combiner::combineMachineInstrs() /home/david/work/llvm-community/llvm-project/llvm/lib/CodeGen/GlobalISel/Combiner.cpp:165:15
#13 0x00007f7d3ae23fea (anonymous namespace)::AArch64PreLegalizerCombiner::runOnMachineFunction(llvm::MachineFunction&) /home/david/work/llvm-community/llvm-project/llvm/lib/Target/AArch64/GISel/AArch64PreLegalizerCombiner.cpp:490:35
#14 0x00007f7d38244366 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) /home/david/work/llvm-community/llvm-project/llvm/lib/CodeGen/MachineFunctionPass.cpp:93:33
#15 0x00007f7d342033c7 llvm::FPPassManager::runOnFunction(llvm::Function&) /home/david/work/llvm-community/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1435:20
#16 0x00007f7d34203695 llvm::FPPassManager::runOnModule(llvm::Module&) /home/david/work/llvm-community/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1481:13
#17 0x00007f7d34203af4 (anonymous namespace)::MPPassManager::runOnModule(llvm::Module&) /home/david/work/llvm-community/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1550:20
#18 0x00007f7d341fe98c llvm::legacy::PassManagerImpl::run(llvm::Module&) /home/david/work/llvm-community/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:535:13
#19 0x00007f7d34204391 llvm::legacy::PassManager::run(llvm::Module&) /home/david/work/llvm-community/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1678:1
#20 0x000055b2213a40ea compileModule(char**, llvm::LLVMContext&) /home/david/work/llvm-community/llvm-project/llvm/tools/llc/llc.cpp:757:66
#21 0x000055b2213a1a59 main /home/david/work/llvm-community/llvm-project/llvm/tools/llc/llc.cpp:416:35
#22 0x00007f7d3310c0b3 __libc_start_main /build/glibc-sMfBJT/glibc-2.31/csu/../csu/libc-start.c:342:3
#23 0x000055b2213a078e _start (/home/david/work/llvm-community/build/bin/llc+0x3278e)`



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


More information about the llvm-commits mailing list