diff options
author | Quentin Colombet <qcolombet@apple.com> | 2017-09-20 17:32:16 +0000 |
---|---|---|
committer | Quentin Colombet <qcolombet@apple.com> | 2017-09-20 17:32:16 +0000 |
commit | aa103b3d86c0bd9d1b4452244173990457af5a4e (patch) | |
tree | e757b8f0c038b9f2ef44896ab06283740aa5ac1a /llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp | |
parent | d0320d528952991138fcc6f30ace0d8cada6d97b (diff) | |
download | bcm5719-llvm-aa103b3d86c0bd9d1b4452244173990457af5a4e.tar.gz bcm5719-llvm-aa103b3d86c0bd9d1b4452244173990457af5a4e.zip |
[InstCombine] Add select simplifications
In these cases, two selects have constant selectable operands for
both the true and false components and have the same conditional
expression.
We then create two arithmetic operations of the same type and feed a
final select operation using the result of the true arithmetic for the true
operand and the result of the false arithmetic for the false operand and reuse
the original conditionl expression.
The arithmetic operations are naturally folded as a consequence, leaving
only the newly formed select to replace the old arithmetic operation.
Patch by: Michael Berg <michael_c_berg@apple.com>
Differential Revision: https://reviews.llvm.org/D37019
llvm-svn: 313774
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp b/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp index c99f757dfef..0f762710fde 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp @@ -736,6 +736,10 @@ Instruction *InstCombiner::visitFMul(BinaryOperator &I) { } } + // Handle specials cases for FMul with selects feeding the operation + if (Value *V = SimplifySelectsFeedingBinaryOp(I, Op0, Op1)) + return replaceInstUsesWith(I, V); + // (X*Y) * X => (X*X) * Y where Y != X // The purpose is two-fold: // 1) to form a power expression (of X). |