1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=instcombine -S | FileCheck %s
9 define i8 @t0_scalar(i8 %x, i8 %y) {
10 ; CHECK-LABEL: @t0_scalar(
11 ; CHECK-NEXT: [[TMP1:%.*]] = xor i8 [[X:%.*]], [[Y:%.*]]
12 ; CHECK-NEXT: [[R:%.*]] = xor i8 [[TMP1]], 42
13 ; CHECK-NEXT: ret i8 [[R]]
20 define <2 x i8> @t1_splatvec(<2 x i8> %x, <2 x i8> %y) {
21 ; CHECK-LABEL: @t1_splatvec(
22 ; CHECK-NEXT: [[TMP1:%.*]] = xor <2 x i8> [[X:%.*]], [[Y:%.*]]
23 ; CHECK-NEXT: [[R:%.*]] = xor <2 x i8> [[TMP1]], <i8 42, i8 42>
24 ; CHECK-NEXT: ret <2 x i8> [[R]]
26 %i0 = xor <2 x i8> %x, <i8 42, i8 42>
27 %r = xor <2 x i8> %i0, %y
30 define <2 x i8> @t2_vec(<2 x i8> %x, <2 x i8> %y) {
31 ; CHECK-LABEL: @t2_vec(
32 ; CHECK-NEXT: [[TMP1:%.*]] = xor <2 x i8> [[X:%.*]], [[Y:%.*]]
33 ; CHECK-NEXT: [[R:%.*]] = xor <2 x i8> [[TMP1]], <i8 42, i8 24>
34 ; CHECK-NEXT: ret <2 x i8> [[R]]
36 %i0 = xor <2 x i8> %x, <i8 42, i8 24>
37 %r = xor <2 x i8> %i0, %y
40 define <2 x i8> @t3_vec_undef(<2 x i8> %x, <2 x i8> %y) {
41 ; CHECK-LABEL: @t3_vec_undef(
42 ; CHECK-NEXT: [[TMP1:%.*]] = xor <2 x i8> [[X:%.*]], [[Y:%.*]]
43 ; CHECK-NEXT: [[R:%.*]] = xor <2 x i8> [[TMP1]], <i8 42, i8 undef>
44 ; CHECK-NEXT: ret <2 x i8> [[R]]
46 %i0 = xor <2 x i8> %x, <i8 42, i8 undef>
47 %r = xor <2 x i8> %i0, %y
51 define i8 @t4_extrause(i8 %x, i8 %y) {
52 ; CHECK-LABEL: @t4_extrause(
53 ; CHECK-NEXT: [[I0:%.*]] = xor i8 [[X:%.*]], 42
54 ; CHECK-NEXT: call void @use8(i8 [[I0]])
55 ; CHECK-NEXT: [[R:%.*]] = xor i8 [[I0]], [[Y:%.*]]
56 ; CHECK-NEXT: ret i8 [[R]]
59 call void @use8(i8 %i0)
64 define i8 @t5_commutativity(i8 %x) {
65 ; CHECK-LABEL: @t5_commutativity(
66 ; CHECK-NEXT: [[Y:%.*]] = call i8 @gen8()
67 ; CHECK-NEXT: [[TMP1:%.*]] = xor i8 [[Y]], [[X:%.*]]
68 ; CHECK-NEXT: [[R:%.*]] = xor i8 [[TMP1]], 42
69 ; CHECK-NEXT: ret i8 [[R]]
77 @global_constant = internal global i32 0, align 4
78 @global_constant2 = internal global i32 0, align 4
80 define i8 @constantexpr(i8 %or) local_unnamed_addr #0 {
81 ; CHECK-LABEL: @constantexpr(
83 ; CHECK-NEXT: [[R:%.*]] = xor i8 [[OR:%.*]], xor (i8 ptrtoint (ptr @global_constant to i8), i8 ptrtoint (ptr @global_constant2 to i8))
84 ; CHECK-NEXT: ret i8 [[R]]
87 %r = xor i8 %or, xor (i8 xor (i8 ptrtoint (ptr @global_constant to i8), i8 -1), i8 xor (i8 ptrtoint (ptr @global_constant2 to i8), i8 -1))
91 @global_constant3 = external global [6 x [1 x i64]], align 1
92 @global_constant4 = external global i64, align 1
93 @global_constant5 = external global ptr, align 1
95 define i16 @constantexpr2() {
96 ; CHECK-LABEL: @constantexpr2(
97 ; CHECK-NEXT: [[I0:%.*]] = icmp ne ptr getelementptr inbounds (i8, ptr @global_constant3, i64 40), @global_constant4
98 ; CHECK-NEXT: [[I1:%.*]] = zext i1 [[I0]] to i16
99 ; CHECK-NEXT: [[I2:%.*]] = load ptr, ptr @global_constant5, align 1
100 ; CHECK-NEXT: [[I3:%.*]] = load i16, ptr [[I2]], align 1
101 ; CHECK-NEXT: [[I4:%.*]] = xor i16 [[I3]], [[I1]]
102 ; CHECK-NEXT: [[I5:%.*]] = xor i16 [[I4]], -1
103 ; CHECK-NEXT: ret i16 [[I5]]
105 %i0 = icmp ne ptr getelementptr inbounds ([6 x [1 x i64]], ptr @global_constant3, i16 0, i16 5, i16 0), @global_constant4
106 %i1 = zext i1 %i0 to i16
107 %i2 = load ptr, ptr @global_constant5, align 1
108 %i3 = load i16, ptr %i2, align 1
109 %i4 = xor i16 %i3, %i1
110 %i5 = xor i16 %i4, -1