[llvm] [InstCombine] Fold adds + shifts with nsw and nuw flags (PR #88193)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Wed May 1 07:08:46 PDT 2024
================
@@ -1259,6 +1259,18 @@ Instruction *InstCombinerImpl::visitLShr(BinaryOperator &I) {
match(Op1, m_SpecificIntAllowPoison(BitWidth - 1)))
return new ZExtInst(Builder.CreateIsNotNeg(X, "isnotneg"), Ty);
+ // If both the add and the shift are nuw, then:
+ // ((X << Z) + Y) nuw >>u Z --> X + (Y >>u Z) nuw
----------------
dtcxzyw wrote:
```suggestion
// ((X <<nuw Z) +nuw Y) >>u Z --> X +nuw (Y >>u Z)
```
https://github.com/llvm/llvm-project/pull/88193
More information about the llvm-commits
mailing list