[llvm-commits] [llvm] r151691 - /llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
Bill Wendling
isanbard at gmail.com
Tue Feb 28 17:46:50 PST 2012
Author: void
Date: Tue Feb 28 19:46:50 2012
New Revision: 151691
URL: http://llvm.org/viewvc/llvm-project?rev=151691&view=rev
Log:
Restrict this transformation to equality conditions.
This transformation is not correct for not-equal conditions:
(trunc x) != C1 & (and x, CA) != C2 -> (and x, CA|CMAX) != C1|C2
Let
C1 == 0
C2 == 0
CA == 0xFF0000
CMAX == 0xFF
and truncating to i8.
The original truth table:
x | A: trunc x != 0 | B: x & 0xFF0000 != 0 | A & B != 0
--------------------------------------------------------------
0x00000 | 0 | 0 | 0
0x00001 | 1 | 0 | 0
0x10000 | 0 | 1 | 0
0x10001 | 1 | 1 | 1
The truth table of the replacement:
x | x & 0xFF00FF != 0
----------------------------
0x00000 | 0
0x00001 | 1
0x10000 | 1
0x10001 | 1
So they are different.
Modified:
llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp?rev=151691&r1=151690&r2=151691&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp Tue Feb 28 19:46:50 2012
@@ -753,7 +753,7 @@
// (trunc x) == C1 & (and x, CA) == C2 -> (and x, CA|CMAX) == C1|C2
// where CMAX is the all ones value for the truncated type,
// iff the lower bits of C2 and CA are zero.
- if (LHSCC == RHSCC && ICmpInst::isEquality(LHSCC) &&
+ if (LHSCC == ICmpInst::ICMP_EQ && LHSCC == RHSCC &&
LHS->hasOneUse() && RHS->hasOneUse()) {
Value *V;
ConstantInt *AndCst, *SmallCst = 0, *BigCst = 0;
More information about the llvm-commits
mailing list