[llvm] [InstCombine] Fold `ucmp/scmp(x, y) >> N` to `zext/sext(x < y)` when N is one less than the width of the result of `ucmp/scmp` (PR #104009)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 14 09:01:24 PDT 2024
================
@@ -511,6 +511,21 @@ Instruction *InstCombinerImpl::commonShiftTransforms(BinaryOperator &I) {
if (match(Op1, m_Or(m_Value(), m_SpecificInt(BitWidth - 1))))
return replaceOperand(I, 1, ConstantInt::get(Ty, BitWidth - 1));
+ Instruction *CmpIntr;
+ if ((I.getOpcode() == Instruction::LShr ||
+ I.getOpcode() == Instruction::AShr) &&
+ match(Op0, m_Instruction(CmpIntr)) && CmpIntr->hasOneUse() &&
----------------
nikic wrote:
```suggestion
match(Op0, m_OneUse(m_Instruction(CmpIntr))) &&
```
https://github.com/llvm/llvm-project/pull/104009
More information about the llvm-commits
mailing list