diff options
author | Sanjay Patel <spatel@rotateright.com> | 2018-07-13 01:18:07 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2018-07-13 01:18:07 +0000 |
commit | 70043b7e9ad7c86c61ac5087aa16c6ed366990e1 (patch) | |
tree | 8dd49ed0bbfb125fb40edd7a0a700d66868431bd /llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp | |
parent | 90ad6835ddaad46efff327db0e2c83bfb1563075 (diff) | |
download | bcm5719-llvm-70043b7e9ad7c86c61ac5087aa16c6ed366990e1.tar.gz bcm5719-llvm-70043b7e9ad7c86c61ac5087aa16c6ed366990e1.zip |
[InstCombine] return when SimplifyAssociativeOrCommutative makes a change
This bug was created by rL335258 because we used to always call instsimplify
after trying the associative folds. After that change it became possible
for subsequent folds to encounter unsimplified code (and potentially assert
because of it).
Instead of carrying changed state through instcombine, we can just return
immediately. This allows instsimplify to run, so we can continue assuming
that easy folds have already occurred.
llvm-svn: 336965
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp b/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp index 65046f26259..a539f870aa2 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp @@ -130,7 +130,9 @@ Instruction *InstCombiner::visitMul(BinaryOperator &I) { SQ.getWithInstruction(&I))) return replaceInstUsesWith(I, V); - bool Changed = SimplifyAssociativeOrCommutative(I); + if (SimplifyAssociativeOrCommutative(I)) + return &I; + if (Instruction *X = foldShuffledBinop(I)) return X; @@ -393,6 +395,7 @@ Instruction *InstCombiner::visitMul(BinaryOperator &I) { } } + bool Changed = false; if (!I.hasNoSignedWrap() && willNotOverflowSignedMul(Op0, Op1, I)) { Changed = true; I.setHasNoSignedWrap(true); @@ -412,7 +415,9 @@ Instruction *InstCombiner::visitFMul(BinaryOperator &I) { SQ.getWithInstruction(&I))) return replaceInstUsesWith(I, V); - bool Changed = SimplifyAssociativeOrCommutative(I); + if (SimplifyAssociativeOrCommutative(I)) + return &I; + if (Instruction *X = foldShuffledBinop(I)) return X; @@ -542,7 +547,7 @@ Instruction *InstCombiner::visitFMul(BinaryOperator &I) { } } - return Changed ? &I : nullptr; + return nullptr; } /// Fold a divide or remainder with a select instruction divisor when one of the |