[llvm] [X86] Handle BSF/BSR "zero-input pass through" behaviour (PR #123623)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 23 02:56:59 PST 2025
================
@@ -5391,9 +5392,9 @@ bool X86InstrInfo::optimizeCompareInstr(MachineInstr &CmpInstr, Register SrcReg,
// ... // EFLAGS not changed
// testl %eax, %eax // <-- can be removed
if (IsCmpZero) {
- NewCC = isUseDefConvertible(Inst);
- if (NewCC != X86::COND_INVALID && Inst.getOperand(1).isReg() &&
- Inst.getOperand(1).getReg() == SrcReg) {
+ std::tie(NewCC, OpNo) = isUseDefConvertible(Inst);
+ if (NewCC != X86::COND_INVALID && Inst.getOperand(OpNo).isReg() &&
+ Inst.getOperand(OpNo).getReg() == SrcReg) {
----------------
RKSimon wrote:
This is at the MI level, and the passthrough/fallback operand is tied to the destination reg (like any x86 binop) - it'd be weird to have a commutation and I expect could lead to further problems.
https://github.com/llvm/llvm-project/pull/123623
More information about the llvm-commits
mailing list