David Majnemer | b5e365c | 2017-01-04 02:21:37 +0000 | [diff] [blame] | 1 | ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py |
| 2 | ; RUN: opt < %s -instcombine -S | FileCheck %s |
| 3 | |
| 4 | target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" |
| 5 | target triple = "x86_64-unknown-linux-gnu" |
| 6 | |
| 7 | declare i32 @callee() |
| 8 | |
Sanjay Patel | 7b9e1af | 2018-09-14 18:05:14 +0000 | [diff] [blame^] | 9 | define i64 @sext_sext_add(i32 %A) { |
| 10 | ; CHECK-LABEL: @sext_sext_add( |
| 11 | ; CHECK-NEXT: [[B:%.*]] = ashr i32 [[A:%.*]], 7 |
| 12 | ; CHECK-NEXT: [[C:%.*]] = ashr i32 [[A]], 9 |
| 13 | ; CHECK-NEXT: [[ADDCONV:%.*]] = add nsw i32 [[B]], [[C]] |
| 14 | ; CHECK-NEXT: [[F:%.*]] = sext i32 [[ADDCONV]] to i64 |
| 15 | ; CHECK-NEXT: ret i64 [[F]] |
| 16 | ; |
| 17 | %B = ashr i32 %A, 7 |
| 18 | %C = ashr i32 %A, 9 |
| 19 | %D = sext i32 %B to i64 |
| 20 | %E = sext i32 %C to i64 |
| 21 | %F = add i64 %D, %E |
| 22 | ret i64 %F |
| 23 | } |
| 24 | |
David Majnemer | b5e365c | 2017-01-04 02:21:37 +0000 | [diff] [blame] | 25 | define i64 @test1(i32 %V) { |
| 26 | ; CHECK-LABEL: @test1( |
| 27 | ; CHECK-NEXT: [[CALL1:%.*]] = call i32 @callee(), !range !0 |
| 28 | ; CHECK-NEXT: [[CALL2:%.*]] = call i32 @callee(), !range !0 |
| 29 | ; CHECK-NEXT: [[ADDCONV:%.*]] = add nuw nsw i32 [[CALL1]], [[CALL2]] |
Sanjay Patel | f7ba0ac | 2018-09-14 17:53:44 +0000 | [diff] [blame] | 30 | ; CHECK-NEXT: [[ADD:%.*]] = zext i32 [[ADDCONV]] to i64 |
David Majnemer | b5e365c | 2017-01-04 02:21:37 +0000 | [diff] [blame] | 31 | ; CHECK-NEXT: ret i64 [[ADD]] |
| 32 | ; |
| 33 | %call1 = call i32 @callee(), !range !0 |
| 34 | %call2 = call i32 @callee(), !range !0 |
| 35 | %zext1 = sext i32 %call1 to i64 |
| 36 | %zext2 = sext i32 %call2 to i64 |
| 37 | %add = add i64 %zext1, %zext2 |
| 38 | ret i64 %add |
| 39 | } |
| 40 | |
| 41 | define i64 @test2(i32 %V) { |
| 42 | ; CHECK-LABEL: @test2( |
| 43 | ; CHECK-NEXT: [[CALL1:%.*]] = call i32 @callee(), !range !0 |
| 44 | ; CHECK-NEXT: [[CALL2:%.*]] = call i32 @callee(), !range !0 |
| 45 | ; CHECK-NEXT: [[ADD:%.*]] = add nuw nsw i32 [[CALL1]], [[CALL2]] |
Sanjay Patel | f7ba0ac | 2018-09-14 17:53:44 +0000 | [diff] [blame] | 46 | ; CHECK-NEXT: [[TMP1:%.*]] = zext i32 [[ADD]] to i64 |
| 47 | ; CHECK-NEXT: ret i64 [[TMP1]] |
David Majnemer | b5e365c | 2017-01-04 02:21:37 +0000 | [diff] [blame] | 48 | ; |
| 49 | %call1 = call i32 @callee(), !range !0 |
| 50 | %call2 = call i32 @callee(), !range !0 |
| 51 | %add = add i32 %call1, %call2 |
| 52 | %zext = sext i32 %add to i64 |
| 53 | ret i64 %zext |
| 54 | } |
| 55 | |
| 56 | define i64 @test3(i32 %V) { |
| 57 | ; CHECK-LABEL: @test3( |
| 58 | ; CHECK-NEXT: [[CALL1:%.*]] = call i32 @callee(), !range !0 |
| 59 | ; CHECK-NEXT: [[CALL2:%.*]] = call i32 @callee(), !range !0 |
| 60 | ; CHECK-NEXT: [[MULCONV:%.*]] = mul nuw nsw i32 [[CALL1]], [[CALL2]] |
| 61 | ; CHECK-NEXT: [[ADD:%.*]] = zext i32 [[MULCONV]] to i64 |
| 62 | ; CHECK-NEXT: ret i64 [[ADD]] |
| 63 | ; |
| 64 | %call1 = call i32 @callee(), !range !0 |
| 65 | %call2 = call i32 @callee(), !range !0 |
| 66 | %zext1 = sext i32 %call1 to i64 |
| 67 | %zext2 = sext i32 %call2 to i64 |
| 68 | %add = mul i64 %zext1, %zext2 |
| 69 | ret i64 %add |
| 70 | } |
| 71 | |
| 72 | define i64 @test4(i32 %V) { |
| 73 | ; CHECK-LABEL: @test4( |
| 74 | ; CHECK-NEXT: [[CALL1:%.*]] = call i32 @callee(), !range !0 |
| 75 | ; CHECK-NEXT: [[CALL2:%.*]] = call i32 @callee(), !range !0 |
| 76 | ; CHECK-NEXT: [[ADD:%.*]] = mul nuw nsw i32 [[CALL1]], [[CALL2]] |
Sanjay Patel | f7ba0ac | 2018-09-14 17:53:44 +0000 | [diff] [blame] | 77 | ; CHECK-NEXT: [[TMP1:%.*]] = zext i32 [[ADD]] to i64 |
| 78 | ; CHECK-NEXT: ret i64 [[TMP1]] |
David Majnemer | b5e365c | 2017-01-04 02:21:37 +0000 | [diff] [blame] | 79 | ; |
| 80 | %call1 = call i32 @callee(), !range !0 |
| 81 | %call2 = call i32 @callee(), !range !0 |
| 82 | %add = mul i32 %call1, %call2 |
| 83 | %zext = sext i32 %add to i64 |
| 84 | ret i64 %zext |
| 85 | } |
| 86 | |
Craig Topper | e23e8a4 | 2018-08-27 22:55:49 +0000 | [diff] [blame] | 87 | define i64 @test5(i32 %V) { |
| 88 | ; CHECK-LABEL: @test5( |
| 89 | ; CHECK-NEXT: [[ASHR:%.*]] = ashr i32 [[V:%.*]], 1 |
| 90 | ; CHECK-NEXT: [[ADDCONV:%.*]] = add nsw i32 [[ASHR]], 1073741823 |
| 91 | ; CHECK-NEXT: [[ADD:%.*]] = sext i32 [[ADDCONV]] to i64 |
| 92 | ; CHECK-NEXT: ret i64 [[ADD]] |
| 93 | ; |
| 94 | %ashr = ashr i32 %V, 1 |
| 95 | %sext = sext i32 %ashr to i64 |
| 96 | %add = add i64 %sext, 1073741823 |
| 97 | ret i64 %add |
| 98 | } |
| 99 | |
| 100 | define <2 x i64> @test5_splat(<2 x i32> %V) { |
| 101 | ; CHECK-LABEL: @test5_splat( |
| 102 | ; CHECK-NEXT: [[ASHR:%.*]] = ashr <2 x i32> [[V:%.*]], <i32 1, i32 1> |
Craig Topper | a6cd4b9 | 2018-08-28 02:02:29 +0000 | [diff] [blame] | 103 | ; CHECK-NEXT: [[ADDCONV:%.*]] = add nsw <2 x i32> [[ASHR]], <i32 1073741823, i32 1073741823> |
| 104 | ; CHECK-NEXT: [[ADD:%.*]] = sext <2 x i32> [[ADDCONV]] to <2 x i64> |
Craig Topper | e23e8a4 | 2018-08-27 22:55:49 +0000 | [diff] [blame] | 105 | ; CHECK-NEXT: ret <2 x i64> [[ADD]] |
| 106 | ; |
| 107 | %ashr = ashr <2 x i32> %V, <i32 1, i32 1> |
| 108 | %sext = sext <2 x i32> %ashr to <2 x i64> |
| 109 | %add = add <2 x i64> %sext, <i64 1073741823, i64 1073741823> |
| 110 | ret <2 x i64> %add |
| 111 | } |
| 112 | |
| 113 | define <2 x i64> @test5_vec(<2 x i32> %V) { |
| 114 | ; CHECK-LABEL: @test5_vec( |
| 115 | ; CHECK-NEXT: [[ASHR:%.*]] = ashr <2 x i32> [[V:%.*]], <i32 1, i32 1> |
Craig Topper | a6cd4b9 | 2018-08-28 02:02:29 +0000 | [diff] [blame] | 116 | ; CHECK-NEXT: [[ADDCONV:%.*]] = add nsw <2 x i32> [[ASHR]], <i32 1, i32 2> |
| 117 | ; CHECK-NEXT: [[ADD:%.*]] = sext <2 x i32> [[ADDCONV]] to <2 x i64> |
Craig Topper | e23e8a4 | 2018-08-27 22:55:49 +0000 | [diff] [blame] | 118 | ; CHECK-NEXT: ret <2 x i64> [[ADD]] |
| 119 | ; |
| 120 | %ashr = ashr <2 x i32> %V, <i32 1, i32 1> |
| 121 | %sext = sext <2 x i32> %ashr to <2 x i64> |
| 122 | %add = add <2 x i64> %sext, <i64 1, i64 2> |
| 123 | ret <2 x i64> %add |
| 124 | } |
| 125 | |
| 126 | define i64 @test6(i32 %V) { |
| 127 | ; CHECK-LABEL: @test6( |
| 128 | ; CHECK-NEXT: [[ASHR:%.*]] = ashr i32 [[V:%.*]], 1 |
| 129 | ; CHECK-NEXT: [[ADDCONV:%.*]] = add nsw i32 [[ASHR]], -1073741824 |
| 130 | ; CHECK-NEXT: [[ADD:%.*]] = sext i32 [[ADDCONV]] to i64 |
| 131 | ; CHECK-NEXT: ret i64 [[ADD]] |
| 132 | ; |
| 133 | %ashr = ashr i32 %V, 1 |
| 134 | %sext = sext i32 %ashr to i64 |
| 135 | %add = add i64 %sext, -1073741824 |
| 136 | ret i64 %add |
| 137 | } |
| 138 | |
| 139 | define <2 x i64> @test6_splat(<2 x i32> %V) { |
| 140 | ; CHECK-LABEL: @test6_splat( |
| 141 | ; CHECK-NEXT: [[ASHR:%.*]] = ashr <2 x i32> [[V:%.*]], <i32 1, i32 1> |
Craig Topper | a6cd4b9 | 2018-08-28 02:02:29 +0000 | [diff] [blame] | 142 | ; CHECK-NEXT: [[ADDCONV:%.*]] = add nsw <2 x i32> [[ASHR]], <i32 -1073741824, i32 -1073741824> |
| 143 | ; CHECK-NEXT: [[ADD:%.*]] = sext <2 x i32> [[ADDCONV]] to <2 x i64> |
Craig Topper | e23e8a4 | 2018-08-27 22:55:49 +0000 | [diff] [blame] | 144 | ; CHECK-NEXT: ret <2 x i64> [[ADD]] |
| 145 | ; |
| 146 | %ashr = ashr <2 x i32> %V, <i32 1, i32 1> |
| 147 | %sext = sext <2 x i32> %ashr to <2 x i64> |
| 148 | %add = add <2 x i64> %sext, <i64 -1073741824, i64 -1073741824> |
| 149 | ret <2 x i64> %add |
| 150 | } |
| 151 | |
| 152 | define <2 x i64> @test6_vec(<2 x i32> %V) { |
| 153 | ; CHECK-LABEL: @test6_vec( |
| 154 | ; CHECK-NEXT: [[ASHR:%.*]] = ashr <2 x i32> [[V:%.*]], <i32 1, i32 1> |
Craig Topper | a6cd4b9 | 2018-08-28 02:02:29 +0000 | [diff] [blame] | 155 | ; CHECK-NEXT: [[ADDCONV:%.*]] = add nsw <2 x i32> [[ASHR]], <i32 -1, i32 -2> |
| 156 | ; CHECK-NEXT: [[ADD:%.*]] = sext <2 x i32> [[ADDCONV]] to <2 x i64> |
Craig Topper | e23e8a4 | 2018-08-27 22:55:49 +0000 | [diff] [blame] | 157 | ; CHECK-NEXT: ret <2 x i64> [[ADD]] |
| 158 | ; |
| 159 | %ashr = ashr <2 x i32> %V, <i32 1, i32 1> |
| 160 | %sext = sext <2 x i32> %ashr to <2 x i64> |
| 161 | %add = add <2 x i64> %sext, <i64 -1, i64 -2> |
| 162 | ret <2 x i64> %add |
| 163 | } |
| 164 | |
| 165 | define <2 x i64> @test6_vec2(<2 x i32> %V) { |
| 166 | ; CHECK-LABEL: @test6_vec2( |
| 167 | ; CHECK-NEXT: [[ASHR:%.*]] = ashr <2 x i32> [[V:%.*]], <i32 1, i32 1> |
Craig Topper | a6cd4b9 | 2018-08-28 02:02:29 +0000 | [diff] [blame] | 168 | ; CHECK-NEXT: [[ADDCONV:%.*]] = add nsw <2 x i32> [[ASHR]], <i32 -1, i32 1> |
| 169 | ; CHECK-NEXT: [[ADD:%.*]] = sext <2 x i32> [[ADDCONV]] to <2 x i64> |
Craig Topper | e23e8a4 | 2018-08-27 22:55:49 +0000 | [diff] [blame] | 170 | ; CHECK-NEXT: ret <2 x i64> [[ADD]] |
| 171 | ; |
| 172 | %ashr = ashr <2 x i32> %V, <i32 1, i32 1> |
| 173 | %sext = sext <2 x i32> %ashr to <2 x i64> |
| 174 | %add = add <2 x i64> %sext, <i64 -1, i64 1> |
| 175 | ret <2 x i64> %add |
| 176 | } |
| 177 | |
| 178 | define i64 @test7(i32 %V) { |
| 179 | ; CHECK-LABEL: @test7( |
| 180 | ; CHECK-NEXT: [[LSHR:%.*]] = lshr i32 [[V:%.*]], 1 |
| 181 | ; CHECK-NEXT: [[ADDCONV:%.*]] = add nuw i32 [[LSHR]], 2147483647 |
| 182 | ; CHECK-NEXT: [[ADD:%.*]] = zext i32 [[ADDCONV]] to i64 |
| 183 | ; CHECK-NEXT: ret i64 [[ADD]] |
| 184 | ; |
| 185 | %lshr = lshr i32 %V, 1 |
| 186 | %zext = zext i32 %lshr to i64 |
| 187 | %add = add i64 %zext, 2147483647 |
| 188 | ret i64 %add |
| 189 | } |
| 190 | |
| 191 | define <2 x i64> @test7_splat(<2 x i32> %V) { |
| 192 | ; CHECK-LABEL: @test7_splat( |
| 193 | ; CHECK-NEXT: [[LSHR:%.*]] = lshr <2 x i32> [[V:%.*]], <i32 1, i32 1> |
Craig Topper | a6cd4b9 | 2018-08-28 02:02:29 +0000 | [diff] [blame] | 194 | ; CHECK-NEXT: [[ADDCONV:%.*]] = add nuw <2 x i32> [[LSHR]], <i32 2147483647, i32 2147483647> |
| 195 | ; CHECK-NEXT: [[ADD:%.*]] = zext <2 x i32> [[ADDCONV]] to <2 x i64> |
Craig Topper | e23e8a4 | 2018-08-27 22:55:49 +0000 | [diff] [blame] | 196 | ; CHECK-NEXT: ret <2 x i64> [[ADD]] |
| 197 | ; |
| 198 | %lshr = lshr <2 x i32> %V, <i32 1, i32 1> |
| 199 | %zext = zext <2 x i32> %lshr to <2 x i64> |
| 200 | %add = add <2 x i64> %zext, <i64 2147483647, i64 2147483647> |
| 201 | ret <2 x i64> %add |
| 202 | } |
| 203 | |
| 204 | define <2 x i64> @test7_vec(<2 x i32> %V) { |
| 205 | ; CHECK-LABEL: @test7_vec( |
| 206 | ; CHECK-NEXT: [[LSHR:%.*]] = lshr <2 x i32> [[V:%.*]], <i32 1, i32 1> |
Craig Topper | a6cd4b9 | 2018-08-28 02:02:29 +0000 | [diff] [blame] | 207 | ; CHECK-NEXT: [[ADDCONV:%.*]] = add nuw <2 x i32> [[LSHR]], <i32 1, i32 2> |
| 208 | ; CHECK-NEXT: [[ADD:%.*]] = zext <2 x i32> [[ADDCONV]] to <2 x i64> |
Craig Topper | e23e8a4 | 2018-08-27 22:55:49 +0000 | [diff] [blame] | 209 | ; CHECK-NEXT: ret <2 x i64> [[ADD]] |
| 210 | ; |
| 211 | %lshr = lshr <2 x i32> %V, <i32 1, i32 1> |
| 212 | %zext = zext <2 x i32> %lshr to <2 x i64> |
| 213 | %add = add <2 x i64> %zext, <i64 1, i64 2> |
| 214 | ret <2 x i64> %add |
| 215 | } |
| 216 | |
Craig Topper | 3de8d59 | 2018-09-10 23:48:21 +0000 | [diff] [blame] | 217 | define i64 @test8(i32 %V) { |
| 218 | ; CHECK-LABEL: @test8( |
| 219 | ; CHECK-NEXT: [[ASHR:%.*]] = ashr i32 [[V:%.*]], 16 |
| 220 | ; CHECK-NEXT: [[MULCONV:%.*]] = mul nsw i32 [[ASHR]], 32767 |
| 221 | ; CHECK-NEXT: [[MUL:%.*]] = sext i32 [[MULCONV]] to i64 |
| 222 | ; CHECK-NEXT: ret i64 [[MUL]] |
| 223 | ; |
| 224 | %ashr = ashr i32 %V, 16 |
| 225 | %sext = sext i32 %ashr to i64 |
| 226 | %mul = mul i64 %sext, 32767 |
| 227 | ret i64 %mul |
| 228 | } |
| 229 | |
| 230 | define <2 x i64> @test8_splat(<2 x i32> %V) { |
| 231 | ; CHECK-LABEL: @test8_splat( |
| 232 | ; CHECK-NEXT: [[ASHR:%.*]] = ashr <2 x i32> [[V:%.*]], <i32 16, i32 16> |
Craig Topper | a57bb61 | 2018-09-11 16:51:24 +0000 | [diff] [blame] | 233 | ; CHECK-NEXT: [[MULCONV:%.*]] = mul nsw <2 x i32> [[ASHR]], <i32 32767, i32 32767> |
| 234 | ; CHECK-NEXT: [[MUL:%.*]] = sext <2 x i32> [[MULCONV]] to <2 x i64> |
Craig Topper | 3de8d59 | 2018-09-10 23:48:21 +0000 | [diff] [blame] | 235 | ; CHECK-NEXT: ret <2 x i64> [[MUL]] |
| 236 | ; |
| 237 | %ashr = ashr <2 x i32> %V, <i32 16, i32 16> |
| 238 | %sext = sext <2 x i32> %ashr to <2 x i64> |
| 239 | %mul = mul <2 x i64> %sext, <i64 32767, i64 32767> |
| 240 | ret <2 x i64> %mul |
| 241 | } |
| 242 | |
| 243 | define <2 x i64> @test8_vec(<2 x i32> %V) { |
| 244 | ; CHECK-LABEL: @test8_vec( |
| 245 | ; CHECK-NEXT: [[ASHR:%.*]] = ashr <2 x i32> [[V:%.*]], <i32 16, i32 16> |
Craig Topper | a57bb61 | 2018-09-11 16:51:24 +0000 | [diff] [blame] | 246 | ; CHECK-NEXT: [[MULCONV:%.*]] = mul nsw <2 x i32> [[ASHR]], <i32 32767, i32 16384> |
| 247 | ; CHECK-NEXT: [[MUL:%.*]] = sext <2 x i32> [[MULCONV]] to <2 x i64> |
Craig Topper | 3de8d59 | 2018-09-10 23:48:21 +0000 | [diff] [blame] | 248 | ; CHECK-NEXT: ret <2 x i64> [[MUL]] |
| 249 | ; |
| 250 | %ashr = ashr <2 x i32> %V, <i32 16, i32 16> |
| 251 | %sext = sext <2 x i32> %ashr to <2 x i64> |
| 252 | %mul = mul <2 x i64> %sext, <i64 32767, i64 16384> |
| 253 | ret <2 x i64> %mul |
| 254 | } |
| 255 | |
| 256 | define <2 x i64> @test8_vec2(<2 x i32> %V) { |
| 257 | ; CHECK-LABEL: @test8_vec2( |
| 258 | ; CHECK-NEXT: [[ASHR:%.*]] = ashr <2 x i32> [[V:%.*]], <i32 16, i32 16> |
Craig Topper | a57bb61 | 2018-09-11 16:51:24 +0000 | [diff] [blame] | 259 | ; CHECK-NEXT: [[MULCONV:%.*]] = mul nsw <2 x i32> [[ASHR]], <i32 32767, i32 -32767> |
| 260 | ; CHECK-NEXT: [[MUL:%.*]] = sext <2 x i32> [[MULCONV]] to <2 x i64> |
Craig Topper | 3de8d59 | 2018-09-10 23:48:21 +0000 | [diff] [blame] | 261 | ; CHECK-NEXT: ret <2 x i64> [[MUL]] |
| 262 | ; |
| 263 | %ashr = ashr <2 x i32> %V, <i32 16, i32 16> |
| 264 | %sext = sext <2 x i32> %ashr to <2 x i64> |
| 265 | %mul = mul <2 x i64> %sext, <i64 32767, i64 -32767> |
| 266 | ret <2 x i64> %mul |
| 267 | } |
| 268 | |
| 269 | define i64 @test9(i32 %V) { |
| 270 | ; CHECK-LABEL: @test9( |
| 271 | ; CHECK-NEXT: [[ASHR:%.*]] = ashr i32 [[V:%.*]], 16 |
| 272 | ; CHECK-NEXT: [[MULCONV:%.*]] = mul nsw i32 [[ASHR]], -32767 |
| 273 | ; CHECK-NEXT: [[MUL:%.*]] = sext i32 [[MULCONV]] to i64 |
| 274 | ; CHECK-NEXT: ret i64 [[MUL]] |
| 275 | ; |
| 276 | %ashr = ashr i32 %V, 16 |
| 277 | %sext = sext i32 %ashr to i64 |
| 278 | %mul = mul i64 %sext, -32767 |
| 279 | ret i64 %mul |
| 280 | } |
| 281 | |
| 282 | define <2 x i64> @test9_splat(<2 x i32> %V) { |
| 283 | ; CHECK-LABEL: @test9_splat( |
| 284 | ; CHECK-NEXT: [[ASHR:%.*]] = ashr <2 x i32> [[V:%.*]], <i32 16, i32 16> |
Craig Topper | a57bb61 | 2018-09-11 16:51:24 +0000 | [diff] [blame] | 285 | ; CHECK-NEXT: [[MULCONV:%.*]] = mul nsw <2 x i32> [[ASHR]], <i32 -32767, i32 -32767> |
| 286 | ; CHECK-NEXT: [[MUL:%.*]] = sext <2 x i32> [[MULCONV]] to <2 x i64> |
Craig Topper | 3de8d59 | 2018-09-10 23:48:21 +0000 | [diff] [blame] | 287 | ; CHECK-NEXT: ret <2 x i64> [[MUL]] |
| 288 | ; |
| 289 | %ashr = ashr <2 x i32> %V, <i32 16, i32 16> |
| 290 | %sext = sext <2 x i32> %ashr to <2 x i64> |
| 291 | %mul = mul <2 x i64> %sext, <i64 -32767, i64 -32767> |
| 292 | ret <2 x i64> %mul |
| 293 | } |
| 294 | |
| 295 | define <2 x i64> @test9_vec(<2 x i32> %V) { |
| 296 | ; CHECK-LABEL: @test9_vec( |
| 297 | ; CHECK-NEXT: [[ASHR:%.*]] = ashr <2 x i32> [[V:%.*]], <i32 16, i32 16> |
Craig Topper | a57bb61 | 2018-09-11 16:51:24 +0000 | [diff] [blame] | 298 | ; CHECK-NEXT: [[MULCONV:%.*]] = mul nsw <2 x i32> [[ASHR]], <i32 -32767, i32 -10> |
| 299 | ; CHECK-NEXT: [[MUL:%.*]] = sext <2 x i32> [[MULCONV]] to <2 x i64> |
Craig Topper | 3de8d59 | 2018-09-10 23:48:21 +0000 | [diff] [blame] | 300 | ; CHECK-NEXT: ret <2 x i64> [[MUL]] |
| 301 | ; |
| 302 | %ashr = ashr <2 x i32> %V, <i32 16, i32 16> |
| 303 | %sext = sext <2 x i32> %ashr to <2 x i64> |
| 304 | %mul = mul <2 x i64> %sext, <i64 -32767, i64 -10> |
| 305 | ret <2 x i64> %mul |
| 306 | } |
| 307 | |
| 308 | define i64 @test10(i32 %V) { |
| 309 | ; CHECK-LABEL: @test10( |
| 310 | ; CHECK-NEXT: [[LSHR:%.*]] = lshr i32 [[V:%.*]], 16 |
| 311 | ; CHECK-NEXT: [[MULCONV:%.*]] = mul nuw i32 [[LSHR]], 65535 |
| 312 | ; CHECK-NEXT: [[MUL:%.*]] = zext i32 [[MULCONV]] to i64 |
| 313 | ; CHECK-NEXT: ret i64 [[MUL]] |
| 314 | ; |
| 315 | %lshr = lshr i32 %V, 16 |
| 316 | %zext = zext i32 %lshr to i64 |
| 317 | %mul = mul i64 %zext, 65535 |
| 318 | ret i64 %mul |
| 319 | } |
| 320 | |
| 321 | define <2 x i64> @test10_splat(<2 x i32> %V) { |
| 322 | ; CHECK-LABEL: @test10_splat( |
| 323 | ; CHECK-NEXT: [[LSHR:%.*]] = lshr <2 x i32> [[V:%.*]], <i32 16, i32 16> |
Craig Topper | a57bb61 | 2018-09-11 16:51:24 +0000 | [diff] [blame] | 324 | ; CHECK-NEXT: [[MULCONV:%.*]] = mul nuw <2 x i32> [[LSHR]], <i32 65535, i32 65535> |
| 325 | ; CHECK-NEXT: [[MUL:%.*]] = zext <2 x i32> [[MULCONV]] to <2 x i64> |
Craig Topper | 3de8d59 | 2018-09-10 23:48:21 +0000 | [diff] [blame] | 326 | ; CHECK-NEXT: ret <2 x i64> [[MUL]] |
| 327 | ; |
| 328 | %lshr = lshr <2 x i32> %V, <i32 16, i32 16> |
| 329 | %zext = zext <2 x i32> %lshr to <2 x i64> |
| 330 | %mul = mul <2 x i64> %zext, <i64 65535, i64 65535> |
| 331 | ret <2 x i64> %mul |
| 332 | } |
| 333 | |
| 334 | define <2 x i64> @test10_vec(<2 x i32> %V) { |
| 335 | ; CHECK-LABEL: @test10_vec( |
| 336 | ; CHECK-NEXT: [[LSHR:%.*]] = lshr <2 x i32> [[V:%.*]], <i32 16, i32 16> |
Craig Topper | a57bb61 | 2018-09-11 16:51:24 +0000 | [diff] [blame] | 337 | ; CHECK-NEXT: [[MULCONV:%.*]] = mul nuw <2 x i32> [[LSHR]], <i32 65535, i32 2> |
| 338 | ; CHECK-NEXT: [[MUL:%.*]] = zext <2 x i32> [[MULCONV]] to <2 x i64> |
Craig Topper | 3de8d59 | 2018-09-10 23:48:21 +0000 | [diff] [blame] | 339 | ; CHECK-NEXT: ret <2 x i64> [[MUL]] |
| 340 | ; |
| 341 | %lshr = lshr <2 x i32> %V, <i32 16, i32 16> |
| 342 | %zext = zext <2 x i32> %lshr to <2 x i64> |
| 343 | %mul = mul <2 x i64> %zext, <i64 65535, i64 2> |
| 344 | ret <2 x i64> %mul |
| 345 | } |
| 346 | |
Craig Topper | e385365 | 2018-09-14 05:16:58 +0000 | [diff] [blame] | 347 | define i64 @test11(i32 %V) { |
| 348 | ; CHECK-LABEL: @test11( |
| 349 | ; CHECK-NEXT: [[CALL1:%.*]] = call i32 @callee(), !range !1 |
| 350 | ; CHECK-NEXT: [[CALL2:%.*]] = call i32 @callee(), !range !1 |
| 351 | ; CHECK-NEXT: [[ADDCONV:%.*]] = add nsw i32 [[CALL1]], [[CALL2]] |
| 352 | ; CHECK-NEXT: [[ADD:%.*]] = sext i32 [[ADDCONV]] to i64 |
| 353 | ; CHECK-NEXT: ret i64 [[ADD]] |
| 354 | ; |
| 355 | %call1 = call i32 @callee(), !range !1 |
| 356 | %call2 = call i32 @callee(), !range !1 |
| 357 | %sext1 = sext i32 %call1 to i64 |
| 358 | %sext2 = sext i32 %call2 to i64 |
| 359 | %add = add i64 %sext1, %sext2 |
| 360 | ret i64 %add |
| 361 | } |
| 362 | |
| 363 | define i64 @test12(i32 %V) { |
| 364 | ; CHECK-LABEL: @test12( |
| 365 | ; CHECK-NEXT: [[CALL1:%.*]] = call i32 @callee(), !range !1 |
| 366 | ; CHECK-NEXT: [[CALL2:%.*]] = call i32 @callee(), !range !1 |
| 367 | ; CHECK-NEXT: [[MULCONV:%.*]] = mul nsw i32 [[CALL1]], [[CALL2]] |
| 368 | ; CHECK-NEXT: [[TMP1:%.*]] = zext i32 [[MULCONV]] to i64 |
| 369 | ; CHECK-NEXT: ret i64 [[TMP1]] |
| 370 | ; |
| 371 | %call1 = call i32 @callee(), !range !1 |
| 372 | %call2 = call i32 @callee(), !range !1 |
| 373 | %sext1 = sext i32 %call1 to i64 |
| 374 | %sext2 = sext i32 %call2 to i64 |
| 375 | %add = mul i64 %sext1, %sext2 |
| 376 | ret i64 %add |
| 377 | } |
| 378 | |
David Majnemer | b5e365c | 2017-01-04 02:21:37 +0000 | [diff] [blame] | 379 | !0 = !{ i32 0, i32 2000 } |
Craig Topper | e385365 | 2018-09-14 05:16:58 +0000 | [diff] [blame] | 380 | !1 = !{ i32 -2000, i32 0 } |