|
| 1 | +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py |
| 2 | +; RUN: opt < %s -instcombine -S | FileCheck %s |
| 3 | + |
| 4 | +declare void @use(i8) |
| 5 | + |
| 6 | +define i8 @sub_not(i8 %x, i8 %y) { |
| 7 | +; CHECK-LABEL: @sub_not( |
| 8 | +; CHECK-NEXT: [[S:%.*]] = sub i8 [[X:%.*]], [[Y:%.*]] |
| 9 | +; CHECK-NEXT: [[R:%.*]] = xor i8 [[S]], -1 |
| 10 | +; CHECK-NEXT: ret i8 [[R]] |
| 11 | +; |
| 12 | + %s = sub i8 %x, %y |
| 13 | + %r = xor i8 %s, -1 |
| 14 | + ret i8 %r |
| 15 | +} |
| 16 | + |
| 17 | +define i8 @sub_not_extra_use(i8 %x, i8 %y) { |
| 18 | +; CHECK-LABEL: @sub_not_extra_use( |
| 19 | +; CHECK-NEXT: [[S:%.*]] = sub i8 [[X:%.*]], [[Y:%.*]] |
| 20 | +; CHECK-NEXT: [[R:%.*]] = xor i8 [[S]], -1 |
| 21 | +; CHECK-NEXT: call void @use(i8 [[S]]) |
| 22 | +; CHECK-NEXT: ret i8 [[R]] |
| 23 | +; |
| 24 | + %s = sub i8 %x, %y |
| 25 | + %r = xor i8 %s, -1 |
| 26 | + call void @use(i8 %s) |
| 27 | + ret i8 %r |
| 28 | +} |
| 29 | + |
| 30 | +define <2 x i8> @sub_not_vec(<2 x i8> %x, <2 x i8> %y) { |
| 31 | +; CHECK-LABEL: @sub_not_vec( |
| 32 | +; CHECK-NEXT: [[S:%.*]] = sub <2 x i8> [[X:%.*]], [[Y:%.*]] |
| 33 | +; CHECK-NEXT: [[R:%.*]] = xor <2 x i8> [[S]], <i8 -1, i8 undef> |
| 34 | +; CHECK-NEXT: ret <2 x i8> [[R]] |
| 35 | +; |
| 36 | + %s = sub <2 x i8> %x, %y |
| 37 | + %r = xor <2 x i8> %s, <i8 -1, i8 undef> |
| 38 | + ret <2 x i8> %r |
| 39 | +} |
| 40 | + |
| 41 | +define i8 @dec_sub(i8 %x, i8 %y) { |
| 42 | +; CHECK-LABEL: @dec_sub( |
| 43 | +; CHECK-NEXT: [[S:%.*]] = sub i8 [[X:%.*]], [[Y:%.*]] |
| 44 | +; CHECK-NEXT: [[R:%.*]] = add i8 [[S]], -1 |
| 45 | +; CHECK-NEXT: ret i8 [[R]] |
| 46 | +; |
| 47 | + %s = sub i8 %x, %y |
| 48 | + %r = add i8 %s, -1 |
| 49 | + ret i8 %r |
| 50 | +} |
| 51 | + |
| 52 | +define i8 @dec_sub_extra_use(i8 %x, i8 %y) { |
| 53 | +; CHECK-LABEL: @dec_sub_extra_use( |
| 54 | +; CHECK-NEXT: [[S:%.*]] = sub i8 [[X:%.*]], [[Y:%.*]] |
| 55 | +; CHECK-NEXT: [[R:%.*]] = add i8 [[S]], -1 |
| 56 | +; CHECK-NEXT: call void @use(i8 [[S]]) |
| 57 | +; CHECK-NEXT: ret i8 [[R]] |
| 58 | +; |
| 59 | + %s = sub i8 %x, %y |
| 60 | + %r = add i8 %s, -1 |
| 61 | + call void @use(i8 %s) |
| 62 | + ret i8 %r |
| 63 | +} |
| 64 | + |
| 65 | +define <2 x i8> @dec_sub_vec(<2 x i8> %x, <2 x i8> %y) { |
| 66 | +; CHECK-LABEL: @dec_sub_vec( |
| 67 | +; CHECK-NEXT: [[S:%.*]] = sub <2 x i8> [[X:%.*]], [[Y:%.*]] |
| 68 | +; CHECK-NEXT: [[R:%.*]] = add <2 x i8> [[S]], <i8 -1, i8 undef> |
| 69 | +; CHECK-NEXT: ret <2 x i8> [[R]] |
| 70 | +; |
| 71 | + %s = sub <2 x i8> %x, %y |
| 72 | + %r = add <2 x i8> %s, <i8 -1, i8 undef> |
| 73 | + ret <2 x i8> %r |
| 74 | +} |
| 75 | + |
| 76 | +define i8 @sub_inc(i8 %x, i8 %y) { |
| 77 | +; CHECK-LABEL: @sub_inc( |
| 78 | +; CHECK-NEXT: [[S:%.*]] = add i8 [[X:%.*]], 1 |
| 79 | +; CHECK-NEXT: [[R:%.*]] = sub i8 [[Y:%.*]], [[S]] |
| 80 | +; CHECK-NEXT: ret i8 [[R]] |
| 81 | +; |
| 82 | + %s = add i8 %x, 1 |
| 83 | + %r = sub i8 %y, %s |
| 84 | + ret i8 %r |
| 85 | +} |
| 86 | + |
| 87 | +define i8 @sub_inc_extra_use(i8 %x, i8 %y) { |
| 88 | +; CHECK-LABEL: @sub_inc_extra_use( |
| 89 | +; CHECK-NEXT: [[S:%.*]] = add i8 [[X:%.*]], 1 |
| 90 | +; CHECK-NEXT: [[R:%.*]] = sub i8 [[Y:%.*]], [[S]] |
| 91 | +; CHECK-NEXT: call void @use(i8 [[S]]) |
| 92 | +; CHECK-NEXT: ret i8 [[R]] |
| 93 | +; |
| 94 | + %s = add i8 %x, 1 |
| 95 | + %r = sub i8 %y, %s |
| 96 | + call void @use(i8 %s) |
| 97 | + ret i8 %r |
| 98 | +} |
| 99 | + |
| 100 | +define <2 x i8> @sub_inc_vec(<2 x i8> %x, <2 x i8> %y) { |
| 101 | +; CHECK-LABEL: @sub_inc_vec( |
| 102 | +; CHECK-NEXT: [[S:%.*]] = add <2 x i8> [[X:%.*]], <i8 undef, i8 1> |
| 103 | +; CHECK-NEXT: [[R:%.*]] = sub <2 x i8> [[Y:%.*]], [[S]] |
| 104 | +; CHECK-NEXT: ret <2 x i8> [[R]] |
| 105 | +; |
| 106 | + %s = add <2 x i8> %x, <i8 undef, i8 1> |
| 107 | + %r = sub <2 x i8> %y, %s |
| 108 | + ret <2 x i8> %r |
| 109 | +} |
| 110 | + |
0 commit comments