1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -instcombine -S | FileCheck %s
4 ; (x&z) ^ (y&z) -> (x^y)&z
5 define i32 @test1(i32 %x, i32 %y, i32 %z) {
7 ; CHECK-NEXT: [[T61:%.*]] = xor i32 [[X:%.*]], [[Y:%.*]]
8 ; CHECK-NEXT: [[T7:%.*]] = and i32 [[T61]], [[Z:%.*]]
9 ; CHECK-NEXT: ret i32 [[T7]]
13 %t7 = xor i32 %t3, %t6
17 ; (x & y) ^ (x|y) -> x^y
18 define i32 @test2(i32 %x, i32 %y, i32 %z) {
19 ; CHECK-LABEL: @test2(
20 ; CHECK-NEXT: [[T7:%.*]] = xor i32 [[Y:%.*]], [[X:%.*]]
21 ; CHECK-NEXT: ret i32 [[T7]]
25 %t7 = xor i32 %t3, %t6
29 define i32 @PR38761(i32 %a, i32 %b) {
30 ; CHECK-LABEL: @PR38761(
31 ; CHECK-NEXT: [[B_LOBIT_NOT1_DEMORGAN:%.*]] = or i32 [[B:%.*]], [[A:%.*]]
32 ; CHECK-NEXT: [[B_LOBIT_NOT1:%.*]] = xor i32 [[B_LOBIT_NOT1_DEMORGAN]], -1
33 ; CHECK-NEXT: [[AND:%.*]] = lshr i32 [[B_LOBIT_NOT1]], 31
34 ; CHECK-NEXT: ret i32 [[AND]]
36 %a.lobit = lshr i32 %a, 31
37 %a.lobit.not = xor i32 %a.lobit, 1
38 %b.lobit = lshr i32 %b, 31
39 %b.lobit.not = xor i32 %b.lobit, 1
40 %and = and i32 %b.lobit.not, %a.lobit.not