[llvm-objdump/MachoDump] Make code much more concise.
[oota-llvm.git] / test / Transforms / InstCombine / demorgan-zext.ll
1 ; RUN: opt < %s -instcombine -S | FileCheck %s
2
3 ; PR22723: Recognize De Morgan's Laws when obfuscated by zexts.
4
5 define i32 @demorgan_or(i1 %X, i1 %Y) {
6   %zextX = zext i1 %X to i32
7   %zextY = zext i1 %Y to i32
8   %notX  = xor i32 %zextX, 1
9   %notY  = xor i32 %zextY, 1
10   %or    = or i32 %notX, %notY
11   ret i32 %or
12
13 ; CHECK-LABEL: demorgan_or(
14 ; CHECK-NEXT:  %[[AND:.*]] = and i1 %X, %Y
15 ; CHECK-NEXT:  %[[ZEXT:.*]] = zext i1 %[[AND]] to i32
16 ; CHECK-NEXT:  %[[XOR:.*]] = xor i32 %[[ZEXT]], 1
17 ; CHECK-NEXT:  ret i32 %[[XOR]]
18 }
19
20 define i32 @demorgan_and(i1 %X, i1 %Y) {
21   %zextX = zext i1 %X to i32
22   %zextY = zext i1 %Y to i32
23   %notX  = xor i32 %zextX, 1
24   %notY  = xor i32 %zextY, 1
25   %and   = and i32 %notX, %notY
26   ret i32 %and
27
28 ; CHECK-LABEL: demorgan_and(
29 ; CHECK-NEXT:  %[[OR:.*]] = or i1 %X, %Y
30 ; CHECK-NEXT:  %[[ZEXT:.*]] = zext i1 %[[OR]] to i32
31 ; CHECK-NEXT:  %[[XOR:.*]] = xor i32 %[[ZEXT]], 1
32 ; CHECK-NEXT:  ret i32 %[[XOR]]
33 }
34