diff options
author | Chris Lattner <sabre@nondot.org> | 2008-06-08 20:52:11 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-06-08 20:52:11 +0000 |
commit | a2417bac03e9f29c4760be5a690eadcb2388a36c (patch) | |
tree | 7bb455da66ddb84b273c823a3639bc57b07bf1f3 /lib | |
parent | abc3b353a52d963b9235e7f06e1b0d7bde0bc477 (diff) | |
download | external_llvm-a2417bac03e9f29c4760be5a690eadcb2388a36c.zip external_llvm-a2417bac03e9f29c4760be5a690eadcb2388a36c.tar.gz external_llvm-a2417bac03e9f29c4760be5a690eadcb2388a36c.tar.bz2 |
Limit the icmp+phi merging optimization to the cases where it is profitable:
don't make i1 phis when it won't be possible to eliminate them.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52097 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Transforms/Scalar/InstructionCombining.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 67c40fe..3b181c8 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -5043,8 +5043,12 @@ Instruction *InstCombiner::visitFCmpInst(FCmpInst &I) { if (Instruction *LHSI = dyn_cast<Instruction>(Op0)) switch (LHSI->getOpcode()) { case Instruction::PHI: - if (Instruction *NV = FoldOpIntoPhi(I)) - return NV; + // Only fold fcmp into the PHI if the phi and fcmp are in the same + // block. If in the same block, we're encouraging jump threading. If + // not, we are just pessimizing the code by making an i1 phi. + if (LHSI->getParent() == I.getParent()) + if (Instruction *NV = FoldOpIntoPhi(I)) + return NV; break; case Instruction::SIToFP: case Instruction::UIToFP: @@ -5348,8 +5352,12 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) { break; case Instruction::PHI: - if (Instruction *NV = FoldOpIntoPhi(I)) - return NV; + // Only fold icmp into the PHI if the phi and fcmp are in the same + // block. If in the same block, we're encouraging jump threading. If + // not, we are just pessimizing the code by making an i1 phi. + if (LHSI->getParent() == I.getParent()) + if (Instruction *NV = FoldOpIntoPhi(I)) + return NV; break; case Instruction::Select: { // If either operand of the select is a constant, we can fold the |