Restrict this transformation to equality conditions.
authorBill Wendling <isanbard@gmail.com>
Wed, 29 Feb 2012 01:46:50 +0000 (01:46 +0000)
committerBill Wendling <isanbard@gmail.com>
Wed, 29 Feb 2012 01:46:50 +0000 (01:46 +0000)
commite1b66f11459c7f1523939fb6ac1dfdc93e1d26ef
treea3ee84afcf3d523ad3c18b9cc727fb01d8ef8826
parenta36fe736458d242e1ae4200c1a8dd42f662851fb
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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151691 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/InstCombine/InstCombineAndOrXor.cpp