diff options
| author | Arnaud A. de Grandmaison <arnaud.adegm@gmail.com> | 2013-03-13 14:40:37 +0000 |
|---|---|---|
| committer | Arnaud A. de Grandmaison <arnaud.adegm@gmail.com> | 2013-03-13 14:40:37 +0000 |
| commit | 7153305b924677c380a360aa488127eec71dd5a2 (patch) | |
| tree | d4ceec6b6ee8137c528d5942a1c558a74e0ddbbc | |
| parent | 59ed15b0525c314648d5adbaef47fbf93b61f0f4 (diff) | |
| download | bcm5719-llvm-7153305b924677c380a360aa488127eec71dd5a2.tar.gz bcm5719-llvm-7153305b924677c380a360aa488127eec71dd5a2.zip | |
Fix a performance regression when combining to smaller types in icmp (shl %v, C1), C2 :
Only combine when the shl is only used by the icmp
llvm-svn: 176950
| -rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp index bad46b4dab3..32fdb9b708b 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp @@ -1333,13 +1333,14 @@ Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI, } // Transform (icmp pred iM (shl iM %v, N), CI) - // -> (icmp pred i(M-N) (trunc %v iM to i(N-N)), (trunc (CI>>N)) - // Transform the shl to a trunc if (trunc (CI>>N)) has no loss. + // -> (icmp pred i(M-N) (trunc %v iM to i(M-N)), (trunc (CI>>N)) + // Transform the shl to a trunc if (trunc (CI>>N)) has no loss and M-N. // This enables to get rid of the shift in favor of a trunc which can be // free on the target. It has the additional benefit of comparing to a // smaller constant, which will be target friendly. unsigned Amt = ShAmt->getLimitedValue(TypeBits-1); - if (Amt != 0 && RHSV.countTrailingZeros() >= Amt) { + if (LHSI->hasOneUse() && + Amt != 0 && RHSV.countTrailingZeros() >= Amt) { Type *NTy = IntegerType::get(ICI.getContext(), TypeBits - Amt); Constant *NCI = ConstantExpr::getTrunc( ConstantExpr::getAShr(RHS, |

