diff options
author | Derek Schuff <dschuff@chromium.org> | 2013-04-02 09:38:08 -0700 |
---|---|---|
committer | Derek Schuff <dschuff@chromium.org> | 2013-04-02 09:38:08 -0700 |
commit | 99681c41b0bf46e9973cf4b3ef6d0b792103f29d (patch) | |
tree | f479307a68fa07023194eb9c0389cf8f5165db47 /lib/Transforms/InstCombine/InstCombineCompares.cpp | |
parent | 26535c655b240324d5cdfcc61bec85d401f71214 (diff) |
Disable shift-compare instcombine optimization for NaCl.
This is one of at least 2 optimizations which introduce non-power-of-two
integer sizes, which we don't want to allow in the PNaCl stable wire format.
This transforms
(icmp pred iM (shl iM %value, N), ConstInt)
-> (icmp pred i(M-N) (trunc %value iM to i(N-N)), (trunc (ConstInt >> N))
and reduces the size of the compare and its operands.
R=mseaborn@chromium.org
BUG= https://code.google.com/p/nativeclient/issues/detail?id=3360
Review URL: https://codereview.chromium.org/13182003
Diffstat (limited to 'lib/Transforms/InstCombine/InstCombineCompares.cpp')
-rw-r--r-- | lib/Transforms/InstCombine/InstCombineCompares.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/Transforms/InstCombine/InstCombineCompares.cpp b/lib/Transforms/InstCombine/InstCombineCompares.cpp index bad46b4dab..0267117421 100644 --- a/lib/Transforms/InstCombine/InstCombineCompares.cpp +++ b/lib/Transforms/InstCombine/InstCombineCompares.cpp @@ -1339,7 +1339,12 @@ Instruction *InstCombiner::visitICmpInstWithInstAndIntCst(ICmpInst &ICI, // 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) { + // @LOCALMOD-BEGIN + // We don't want to introduce non-power-of-two integer sizes for PNaCl's + // stable wire format, so modify this transformation for NaCl. + if (Amt != 0 && RHSV.countTrailingZeros() >= Amt && + isPowerOf2_32(TypeBits - Amt) && (TypeBits - Amt) >= 8) { + // @LOCALMOD-END Type *NTy = IntegerType::get(ICI.getContext(), TypeBits - Amt); Constant *NCI = ConstantExpr::getTrunc( ConstantExpr::getAShr(RHS, |