|
| 1 | +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py |
| 2 | +; RUN: opt -passes=instsimplify < %s -S | FileCheck %s |
| 3 | + |
| 4 | +define i1 @shl_C_X_ugt(i8 %x) { |
| 5 | +; CHECK-LABEL: @shl_C_X_ugt( |
| 6 | +; CHECK-NEXT: [[SHL:%.*]] = shl i8 7, [[X:%.*]] |
| 7 | +; CHECK-NEXT: [[R:%.*]] = icmp ugt i8 [[SHL]], -32 |
| 8 | +; CHECK-NEXT: ret i1 [[R]] |
| 9 | +; |
| 10 | + %shl = shl i8 7, %x |
| 11 | + %r = icmp ugt i8 %shl, 224 |
| 12 | + ret i1 %r |
| 13 | +} |
| 14 | + |
| 15 | +define i1 @shl_C_X_ugt2(i8 %x) { |
| 16 | +; CHECK-LABEL: @shl_C_X_ugt2( |
| 17 | +; CHECK-NEXT: [[SHL:%.*]] = shl i8 5, [[X:%.*]] |
| 18 | +; CHECK-NEXT: [[R:%.*]] = icmp ugt i8 [[SHL]], -64 |
| 19 | +; CHECK-NEXT: ret i1 [[R]] |
| 20 | +; |
| 21 | + %shl = shl i8 5, %x |
| 22 | + %r = icmp ugt i8 %shl, 192 |
| 23 | + ret i1 %r |
| 24 | +} |
| 25 | + |
| 26 | +define i1 @shl_C_X_ugt_fail(i8 %x) { |
| 27 | +; CHECK-LABEL: @shl_C_X_ugt_fail( |
| 28 | +; CHECK-NEXT: [[SHL:%.*]] = shl i8 1, [[X:%.*]] |
| 29 | +; CHECK-NEXT: [[R:%.*]] = icmp ugt i8 [[SHL]], 127 |
| 30 | +; CHECK-NEXT: ret i1 [[R]] |
| 31 | +; |
| 32 | + %shl = shl i8 1, %x |
| 33 | + %r = icmp ugt i8 %shl, 127 |
| 34 | + ret i1 %r |
| 35 | +} |
| 36 | + |
| 37 | +define i1 @shl_C_X_ugt_fail2(i8 %x) { |
| 38 | +; CHECK-LABEL: @shl_C_X_ugt_fail2( |
| 39 | +; CHECK-NEXT: [[SHL:%.*]] = shl i8 3, [[X:%.*]] |
| 40 | +; CHECK-NEXT: [[R:%.*]] = icmp ugt i8 [[SHL]], -66 |
| 41 | +; CHECK-NEXT: ret i1 [[R]] |
| 42 | +; |
| 43 | + %shl = shl i8 3, %x |
| 44 | + %r = icmp ugt i8 %shl, 190 |
| 45 | + ret i1 %r |
| 46 | +} |
| 47 | + |
| 48 | +define i1 @shl_C_X_ugt_fail3(i8 %x) { |
| 49 | +; CHECK-LABEL: @shl_C_X_ugt_fail3( |
| 50 | +; CHECK-NEXT: [[SHL:%.*]] = shl i8 -1, [[X:%.*]] |
| 51 | +; CHECK-NEXT: [[R:%.*]] = icmp ugt i8 [[SHL]], -2 |
| 52 | +; CHECK-NEXT: ret i1 [[R]] |
| 53 | +; |
| 54 | + %shl = shl i8 -1, %x |
| 55 | + %r = icmp ugt i8 %shl, 254 |
| 56 | + ret i1 %r |
| 57 | +} |
| 58 | + |
| 59 | +define i1 @shl_C_X_ugt_todo(i8 %x) { |
| 60 | +; CHECK-LABEL: @shl_C_X_ugt_todo( |
| 61 | +; CHECK-NEXT: [[SHL:%.*]] = shl i8 -127, [[X:%.*]] |
| 62 | +; CHECK-NEXT: [[R:%.*]] = icmp ugt i8 [[SHL]], -116 |
| 63 | +; CHECK-NEXT: ret i1 [[R]] |
| 64 | +; |
| 65 | + %shl = shl i8 129, %x |
| 66 | + %r = icmp ugt i8 %shl, 140 |
| 67 | + ret i1 %r |
| 68 | +} |
| 69 | + |
| 70 | +define i1 @shl_X_C_ugt(i8 %x) { |
| 71 | +; CHECK-LABEL: @shl_X_C_ugt( |
| 72 | +; CHECK-NEXT: [[SHL:%.*]] = shl i8 [[X:%.*]], 6 |
| 73 | +; CHECK-NEXT: [[R:%.*]] = icmp ugt i8 [[SHL]], -64 |
| 74 | +; CHECK-NEXT: ret i1 [[R]] |
| 75 | +; |
| 76 | + %shl = shl i8 %x, 6 |
| 77 | + %r = icmp ugt i8 %shl, 192 |
| 78 | + ret i1 %r |
| 79 | +} |
| 80 | + |
| 81 | +define i1 @shl_X_C_ugt_fail(i8 %x) { |
| 82 | +; CHECK-LABEL: @shl_X_C_ugt_fail( |
| 83 | +; CHECK-NEXT: [[SHL:%.*]] = shl i8 [[X:%.*]], 6 |
| 84 | +; CHECK-NEXT: [[R:%.*]] = icmp ugt i8 [[SHL]], -65 |
| 85 | +; CHECK-NEXT: ret i1 [[R]] |
| 86 | +; |
| 87 | + %shl = shl i8 %x, 6 |
| 88 | + %r = icmp ugt i8 %shl, 191 |
| 89 | + ret i1 %r |
| 90 | +} |
| 91 | + |
| 92 | +define i1 @shl_X_C_ugt_fail2(i8 %x) { |
| 93 | +; CHECK-LABEL: @shl_X_C_ugt_fail2( |
| 94 | +; CHECK-NEXT: [[SHL:%.*]] = shl i8 [[X:%.*]], 5 |
| 95 | +; CHECK-NEXT: [[R:%.*]] = icmp ugt i8 [[SHL]], -64 |
| 96 | +; CHECK-NEXT: ret i1 [[R]] |
| 97 | +; |
| 98 | + %shl = shl i8 %x, 5 |
| 99 | + %r = icmp ugt i8 %shl, 192 |
| 100 | + ret i1 %r |
| 101 | +} |
| 102 | + |
| 103 | +define i1 @and_ugt(i8 %xx) { |
| 104 | +; CHECK-LABEL: @and_ugt( |
| 105 | +; CHECK-NEXT: [[X:%.*]] = mul i8 [[XX:%.*]], [[XX]] |
| 106 | +; CHECK-NEXT: [[NEGX:%.*]] = sub i8 0, [[X]] |
| 107 | +; CHECK-NEXT: [[X_P2:%.*]] = and i8 [[NEGX]], [[X]] |
| 108 | +; CHECK-NEXT: [[R:%.*]] = icmp ugt i8 [[X_P2]], -128 |
| 109 | +; CHECK-NEXT: ret i1 [[R]] |
| 110 | +; |
| 111 | + %x = mul i8 %xx, %xx ; thwart complexity-based canonicalization |
| 112 | + %negx = sub i8 0, %x |
| 113 | + %x_p2 = and i8 %negx, %x |
| 114 | + %r = icmp ugt i8 %x_p2, 128 |
| 115 | + ret i1 %r |
| 116 | +} |
| 117 | + |
| 118 | +define i1 @and_ugt2(i8 %xx) { |
| 119 | +; CHECK-LABEL: @and_ugt2( |
| 120 | +; CHECK-NEXT: [[X:%.*]] = mul i8 [[XX:%.*]], [[XX]] |
| 121 | +; CHECK-NEXT: [[NEGX:%.*]] = sub i8 0, [[X]] |
| 122 | +; CHECK-NEXT: [[X_P2:%.*]] = and i8 [[X]], [[NEGX]] |
| 123 | +; CHECK-NEXT: [[R:%.*]] = icmp ugt i8 [[X_P2]], -128 |
| 124 | +; CHECK-NEXT: ret i1 [[R]] |
| 125 | +; |
| 126 | + %x = mul i8 %xx, %xx ; thwart complexity-based canonicalization |
| 127 | + %negx = sub i8 0, %x |
| 128 | + %x_p2 = and i8 %x, %negx |
| 129 | + %r = icmp ugt i8 %x_p2, 128 |
| 130 | + ret i1 %r |
| 131 | +} |
| 132 | + |
| 133 | +define i1 @and_ugt_fail(i8 %xx) { |
| 134 | +; CHECK-LABEL: @and_ugt_fail( |
| 135 | +; CHECK-NEXT: [[X:%.*]] = mul i8 [[XX:%.*]], [[XX]] |
| 136 | +; CHECK-NEXT: [[NEGX:%.*]] = sub i8 0, [[X]] |
| 137 | +; CHECK-NEXT: [[X_P2:%.*]] = and i8 [[X]], [[NEGX]] |
| 138 | +; CHECK-NEXT: [[R:%.*]] = icmp ugt i8 [[X_P2]], 127 |
| 139 | +; CHECK-NEXT: ret i1 [[R]] |
| 140 | +; |
| 141 | + %x = mul i8 %xx, %xx ; thwart complexity-based canonicalization |
| 142 | + %negx = sub i8 0, %x |
| 143 | + %x_p2 = and i8 %x, %negx |
| 144 | + %r = icmp ugt i8 %x_p2, 127 |
| 145 | + ret i1 %r |
| 146 | +} |
0 commit comments