diff options
author | Chad Rosier <mcrosier@codeaurora.org> | 2017-09-27 17:16:51 +0000 |
---|---|---|
committer | Chad Rosier <mcrosier@codeaurora.org> | 2017-09-27 17:16:51 +0000 |
commit | d8b4b06f5d03e7461918c3e380bc2dd3334afa55 (patch) | |
tree | 4c3b38c70f1099caa760b8007265448ca9e76767 /llvm/lib/Transforms | |
parent | c032b2beb08471cb4599f263c82ea4b4f5a42ad8 (diff) | |
download | bcm5719-llvm-d8b4b06f5d03e7461918c3e380bc2dd3334afa55.tar.gz bcm5719-llvm-d8b4b06f5d03e7461918c3e380bc2dd3334afa55.zip |
[InstCombine] Gating select arithmetic optimization.
These changes faciliate positive behavior for arithmetic based select
expressions that match its translation criteria, keeping code size gated to
neutral or improved scenarios.
Patch by Michael Berg <michael_c_berg@apple.com>!
Differential Revision: https://reviews.llvm.org/D38263
llvm-svn: 314320
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstructionCombining.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp index 60db2ddb63c..2271e219d0f 100644 --- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp +++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp @@ -731,6 +731,7 @@ Value *InstCombiner::SimplifySelectsFeedingBinaryOp(BinaryOperator &I, Value *SI = nullptr; if (match(LHS, m_Select(m_Value(A), m_Value(B), m_Value(C))) && match(RHS, m_Select(m_Specific(A), m_Value(D), m_Value(E)))) { + bool SelectsHaveOneUse = LHS->hasOneUse() && RHS->hasOneUse(); BuilderTy::FastMathFlagGuard Guard(Builder); if (isa<FPMathOperator>(&I)) Builder.setFastMathFlags(I.getFastMathFlags()); @@ -739,9 +740,9 @@ Value *InstCombiner::SimplifySelectsFeedingBinaryOp(BinaryOperator &I, Value *V2 = SimplifyBinOp(Opcode, B, D, SQ.getWithInstruction(&I)); if (V1 && V2) SI = Builder.CreateSelect(A, V2, V1); - else if (V2) + else if (V2 && SelectsHaveOneUse) SI = Builder.CreateSelect(A, V2, Builder.CreateBinOp(Opcode, C, E)); - else if (V1) + else if (V1 && SelectsHaveOneUse) SI = Builder.CreateSelect(A, Builder.CreateBinOp(Opcode, B, D), V1); if (SI) |