[PATCH] D132658: [InstCombine] Distributive or+mul with const operand
chenglin.bi via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 28 20:48:40 PDT 2022
bcl5980 added inline comments.
================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp:240
auto *BO = BinaryOperator::CreateAdd(NewMul, NewC);
auto *NewMulBO = dyn_cast<BinaryOperator>(NewMul);
+ if (I.hasNoUnsignedWrap() && Op0NUW && NewMulBO) {
----------------
bcl5980 wrote:
> If NewMulBO is constant we also can set BO to nuw. So the logic should be this
> ```
> if (I.hasNoUnsignedWrap() && Op0NUW && NewMulBO) {
> if (auto *NewMulBO = dyn_cast<BinaryOperator>(NewMul))
> NewMulBO->setHasNoUnsignedWrap();
> BO->setHasNoUnsignedWrap();
> }
> ```
Sorry should be this one:
```
if (I.hasNoUnsignedWrap() && Op0NUW) {
if (auto *NewMulBO = dyn_cast<BinaryOperator>(NewMul))
NewMulBO->setHasNoUnsignedWrap();
BO->setHasNoUnsignedWrap();
}
```
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D132658/new/
https://reviews.llvm.org/D132658
More information about the llvm-commits
mailing list