|
| 1 | +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py |
| 2 | +; RUN: opt -passes=instcombine -S -o - %s | FileCheck %s |
| 3 | + |
| 4 | +declare void @use.i8(i8) |
| 5 | +declare void @use.v2i8(<2 x i8>) |
| 6 | +define i1 @src_add_eq_p2(i8 %x, i8 %yy) { |
| 7 | +; CHECK-LABEL: @src_add_eq_p2( |
| 8 | +; CHECK-NEXT: [[NY:%.*]] = sub i8 0, [[YY:%.*]] |
| 9 | +; CHECK-NEXT: [[Y:%.*]] = and i8 [[NY]], [[YY]] |
| 10 | +; CHECK-NEXT: [[X1:%.*]] = add i8 [[Y]], [[X:%.*]] |
| 11 | +; CHECK-NEXT: call void @use.i8(i8 [[X1]]) |
| 12 | +; CHECK-NEXT: [[V:%.*]] = and i8 [[X1]], [[Y]] |
| 13 | +; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[V]], [[Y]] |
| 14 | +; CHECK-NEXT: ret i1 [[R]] |
| 15 | +; |
| 16 | + %ny = sub i8 0, %yy |
| 17 | + %y = and i8 %ny, %yy |
| 18 | + %x1 = add i8 %y, %x |
| 19 | + call void @use.i8(i8 %x1) |
| 20 | + %v = and i8 %x1, %y |
| 21 | + %r = icmp eq i8 %v, %y |
| 22 | + ret i1 %r |
| 23 | +} |
| 24 | + |
| 25 | +define i1 @src_add_eq_p2_fail_multiuse(i8 %x, i8 %yy) { |
| 26 | +; CHECK-LABEL: @src_add_eq_p2_fail_multiuse( |
| 27 | +; CHECK-NEXT: [[NY:%.*]] = sub i8 0, [[YY:%.*]] |
| 28 | +; CHECK-NEXT: [[Y:%.*]] = and i8 [[NY]], [[YY]] |
| 29 | +; CHECK-NEXT: [[X1:%.*]] = add i8 [[Y]], [[X:%.*]] |
| 30 | +; CHECK-NEXT: call void @use.i8(i8 [[X1]]) |
| 31 | +; CHECK-NEXT: [[V:%.*]] = and i8 [[X1]], [[Y]] |
| 32 | +; CHECK-NEXT: call void @use.i8(i8 [[V]]) |
| 33 | +; CHECK-NEXT: [[R:%.*]] = icmp eq i8 [[V]], [[Y]] |
| 34 | +; CHECK-NEXT: ret i1 [[R]] |
| 35 | +; |
| 36 | + %ny = sub i8 0, %yy |
| 37 | + %y = and i8 %ny, %yy |
| 38 | + %x1 = add i8 %x, %y |
| 39 | + call void @use.i8(i8 %x1) |
| 40 | + %v = and i8 %x1, %y |
| 41 | + call void @use.i8(i8 %v) |
| 42 | + %r = icmp eq i8 %v, %y |
| 43 | + ret i1 %r |
| 44 | +} |
| 45 | + |
| 46 | +define i1 @src_xor_ne_zero(i8 %x, i8 %yy) { |
| 47 | +; CHECK-LABEL: @src_xor_ne_zero( |
| 48 | +; CHECK-NEXT: [[NY:%.*]] = sub i8 0, [[YY:%.*]] |
| 49 | +; CHECK-NEXT: [[Y:%.*]] = and i8 [[NY]], [[YY]] |
| 50 | +; CHECK-NEXT: [[X1:%.*]] = xor i8 [[Y]], [[X:%.*]] |
| 51 | +; CHECK-NEXT: call void @use.i8(i8 [[X1]]) |
| 52 | +; CHECK-NEXT: [[V:%.*]] = and i8 [[X1]], [[Y]] |
| 53 | +; CHECK-NEXT: [[R:%.*]] = icmp ne i8 [[V]], 0 |
| 54 | +; CHECK-NEXT: ret i1 [[R]] |
| 55 | +; |
| 56 | + %ny = sub i8 0, %yy |
| 57 | + %y = and i8 %ny, %yy |
| 58 | + %x1 = xor i8 %x, %y |
| 59 | + call void @use.i8(i8 %x1) |
| 60 | + %v = and i8 %x1, %y |
| 61 | + %r = icmp ne i8 %v, 0 |
| 62 | + ret i1 %r |
| 63 | +} |
| 64 | + |
| 65 | +define i1 @src_xor_ne_zero_fail_different_p2(i8 %x, i8 %yy) { |
| 66 | +; CHECK-LABEL: @src_xor_ne_zero_fail_different_p2( |
| 67 | +; CHECK-NEXT: [[NY:%.*]] = sub i8 0, [[YY:%.*]] |
| 68 | +; CHECK-NEXT: [[Y:%.*]] = and i8 [[NY]], [[YY]] |
| 69 | +; CHECK-NEXT: [[Y2:%.*]] = shl i8 [[Y]], 1 |
| 70 | +; CHECK-NEXT: [[X1:%.*]] = xor i8 [[Y]], [[X:%.*]] |
| 71 | +; CHECK-NEXT: call void @use.i8(i8 [[X1]]) |
| 72 | +; CHECK-NEXT: [[V:%.*]] = and i8 [[X1]], [[Y2]] |
| 73 | +; CHECK-NEXT: [[R:%.*]] = icmp ne i8 [[V]], 0 |
| 74 | +; CHECK-NEXT: ret i1 [[R]] |
| 75 | +; |
| 76 | + %ny = sub i8 0, %yy |
| 77 | + %y = and i8 %ny, %yy |
| 78 | + %y2 = shl i8 %y, 1 |
| 79 | + %x1 = xor i8 %x, %y |
| 80 | + call void @use.i8(i8 %x1) |
| 81 | + %v = and i8 %x1, %y2 |
| 82 | + %r = icmp ne i8 %v, 0 |
| 83 | + ret i1 %r |
| 84 | +} |
| 85 | + |
| 86 | +define <2 x i1> @src_sub_ne_p2(<2 x i8> %x, <2 x i8> %yy) { |
| 87 | +; CHECK-LABEL: @src_sub_ne_p2( |
| 88 | +; CHECK-NEXT: [[NY:%.*]] = sub <2 x i8> zeroinitializer, [[YY:%.*]] |
| 89 | +; CHECK-NEXT: [[Y:%.*]] = and <2 x i8> [[NY]], [[YY]] |
| 90 | +; CHECK-NEXT: [[X1:%.*]] = sub <2 x i8> [[X:%.*]], [[Y]] |
| 91 | +; CHECK-NEXT: call void @use.v2i8(<2 x i8> [[X1]]) |
| 92 | +; CHECK-NEXT: [[V:%.*]] = and <2 x i8> [[X1]], [[Y]] |
| 93 | +; CHECK-NEXT: [[R:%.*]] = icmp ne <2 x i8> [[V]], [[Y]] |
| 94 | +; CHECK-NEXT: ret <2 x i1> [[R]] |
| 95 | +; |
| 96 | + %ny = sub <2 x i8> zeroinitializer, %yy |
| 97 | + %y = and <2 x i8> %ny, %yy |
| 98 | + %x1 = sub <2 x i8> %x, %y |
| 99 | + call void @use.v2i8(<2 x i8> %x1) |
| 100 | + %v = and <2 x i8> %x1, %y |
| 101 | + %r = icmp ne <2 x i8> %v, %y |
| 102 | + ret <2 x i1> %r |
| 103 | +} |
| 104 | + |
| 105 | +define <2 x i1> @src_sub_eq_zero(<2 x i8> %x, <2 x i8> %yy) { |
| 106 | +; CHECK-LABEL: @src_sub_eq_zero( |
| 107 | +; CHECK-NEXT: [[Y:%.*]] = shl <2 x i8> <i8 1, i8 2>, [[YY:%.*]] |
| 108 | +; CHECK-NEXT: [[X1:%.*]] = sub <2 x i8> [[X:%.*]], [[Y]] |
| 109 | +; CHECK-NEXT: call void @use.v2i8(<2 x i8> [[X1]]) |
| 110 | +; CHECK-NEXT: [[V:%.*]] = and <2 x i8> [[X1]], [[Y]] |
| 111 | +; CHECK-NEXT: [[R:%.*]] = icmp eq <2 x i8> [[V]], zeroinitializer |
| 112 | +; CHECK-NEXT: ret <2 x i1> [[R]] |
| 113 | +; |
| 114 | + %y = shl <2 x i8> <i8 1, i8 2>, %yy |
| 115 | + %x1 = sub <2 x i8> %x, %y |
| 116 | + call void @use.v2i8(<2 x i8> %x1) |
| 117 | + %v = and <2 x i8> %x1, %y |
| 118 | + %r = icmp eq <2 x i8> %v, zeroinitializer |
| 119 | + ret <2 x i1> %r |
| 120 | +} |
| 121 | + |
| 122 | +define <2 x i1> @src_sub_eq_zero_fail_commuted(<2 x i8> %x, <2 x i8> %yy) { |
| 123 | +; CHECK-LABEL: @src_sub_eq_zero_fail_commuted( |
| 124 | +; CHECK-NEXT: [[Y:%.*]] = shl <2 x i8> <i8 1, i8 2>, [[YY:%.*]] |
| 125 | +; CHECK-NEXT: [[X1:%.*]] = sub <2 x i8> [[Y]], [[X:%.*]] |
| 126 | +; CHECK-NEXT: call void @use.v2i8(<2 x i8> [[X1]]) |
| 127 | +; CHECK-NEXT: [[V:%.*]] = and <2 x i8> [[X1]], [[Y]] |
| 128 | +; CHECK-NEXT: [[R:%.*]] = icmp eq <2 x i8> [[V]], zeroinitializer |
| 129 | +; CHECK-NEXT: ret <2 x i1> [[R]] |
| 130 | +; |
| 131 | + %y = shl <2 x i8> <i8 1, i8 2>, %yy |
| 132 | + %x1 = sub <2 x i8> %y, %x |
| 133 | + call void @use.v2i8(<2 x i8> %x1) |
| 134 | + %v = and <2 x i8> %x1, %y |
| 135 | + %r = icmp eq <2 x i8> %v, zeroinitializer |
| 136 | + ret <2 x i1> %r |
| 137 | +} |
| 138 | + |
| 139 | +define <2 x i1> @src_sub_eq_zero_fail_non_p2(<2 x i8> %x, <2 x i8> %yy) { |
| 140 | +; CHECK-LABEL: @src_sub_eq_zero_fail_non_p2( |
| 141 | +; CHECK-NEXT: [[Y:%.*]] = shl <2 x i8> <i8 1, i8 3>, [[YY:%.*]] |
| 142 | +; CHECK-NEXT: [[X1:%.*]] = sub <2 x i8> [[X:%.*]], [[Y]] |
| 143 | +; CHECK-NEXT: call void @use.v2i8(<2 x i8> [[X1]]) |
| 144 | +; CHECK-NEXT: [[V:%.*]] = and <2 x i8> [[X1]], [[Y]] |
| 145 | +; CHECK-NEXT: [[R:%.*]] = icmp eq <2 x i8> [[V]], zeroinitializer |
| 146 | +; CHECK-NEXT: ret <2 x i1> [[R]] |
| 147 | +; |
| 148 | + %y = shl <2 x i8> <i8 1, i8 3>, %yy |
| 149 | + %x1 = sub <2 x i8> %x, %y |
| 150 | + call void @use.v2i8(<2 x i8> %x1) |
| 151 | + %v = and <2 x i8> %x1, %y |
| 152 | + %r = icmp eq <2 x i8> %v, zeroinitializer |
| 153 | + ret <2 x i1> %r |
| 154 | +} |
0 commit comments