1 ; RUN: opt -instsimplify -S < %s | FileCheck %s 2 3 define i64 @test0() { 4 ; CHECK-LABEL: @test0( 5 ; CHECK: ret i64 undef 6 ; 7 %r = mul i64 undef, undef 8 ret i64 %r 9 } 10 11 define i64 @test1() { 12 ; CHECK-LABEL: @test1( 13 ; CHECK: ret i64 undef 14 ; 15 %r = mul i64 3, undef 16 ret i64 %r 17 } 18 19 define i64 @test2() { 20 ; CHECK-LABEL: @test2( 21 ; CHECK: ret i64 undef 22 ; 23 %r = mul i64 undef, 3 24 ret i64 %r 25 } 26 27 define i64 @test3() { 28 ; CHECK-LABEL: @test3( 29 ; CHECK: ret i64 0 30 ; 31 %r = mul i64 undef, 6 32 ret i64 %r 33 } 34 35 define i64 @test4() { 36 ; CHECK-LABEL: @test4( 37 ; CHECK: ret i64 0 38 ; 39 %r = mul i64 6, undef 40 ret i64 %r 41 } 42 43 define i64 @test5() { 44 ; CHECK-LABEL: @test5( 45 ; CHECK: ret i64 undef 46 ; 47 %r = and i64 undef, undef 48 ret i64 %r 49 } 50 51 define i64 @test6() { 52 ; CHECK-LABEL: @test6( 53 ; CHECK: ret i64 undef 54 ; 55 %r = or i64 undef, undef 56 ret i64 %r 57 } 58 59 define i64 @test7() { 60 ; CHECK-LABEL: @test7( 61 ; CHECK: ret i64 undef 62 ; 63 %r = udiv i64 undef, 1 64 ret i64 %r 65 } 66 67 define i64 @test8() { 68 ; CHECK-LABEL: @test8( 69 ; CHECK: ret i64 undef 70 ; 71 %r = sdiv i64 undef, 1 72 ret i64 %r 73 } 74 75 define i64 @test9() { 76 ; CHECK-LABEL: @test9( 77 ; CHECK: ret i64 0 78 ; 79 %r = urem i64 undef, 1 80 ret i64 %r 81 } 82 83 define i64 @test10() { 84 ; CHECK-LABEL: @test10( 85 ; CHECK: ret i64 0 86 ; 87 %r = srem i64 undef, 1 88 ret i64 %r 89 } 90 91 define i64 @test11() { 92 ; CHECK-LABEL: @test11( 93 ; CHECK: ret i64 undef 94 ; 95 %r = shl i64 undef, undef 96 ret i64 %r 97 } 98 99 define i64 @test11b(i64 %a) { 100 ; CHECK-LABEL: @test11b( 101 ; CHECK: ret i64 undef 102 ; 103 %r = shl i64 %a, undef 104 ret i64 %r 105 } 106 107 define i64 @test12() { 108 ; CHECK-LABEL: @test12( 109 ; CHECK: ret i64 undef 110 ; 111 %r = ashr i64 undef, undef 112 ret i64 %r 113 } 114 115 define i64 @test12b(i64 %a) { 116 ; CHECK-LABEL: @test12b( 117 ; CHECK: ret i64 undef 118 ; 119 %r = ashr i64 %a, undef 120 ret i64 %r 121 } 122 123 define i64 @test13() { 124 ; CHECK-LABEL: @test13( 125 ; CHECK: ret i64 undef 126 ; 127 %r = lshr i64 undef, undef 128 ret i64 %r 129 } 130 131 define i64 @test13b(i64 %a) { 132 ; CHECK-LABEL: @test13b( 133 ; CHECK: ret i64 undef 134 ; 135 %r = lshr i64 %a, undef 136 ret i64 %r 137 } 138 139 define i1 @test14() { 140 ; CHECK-LABEL: @test14( 141 ; CHECK: ret i1 undef 142 ; 143 %r = icmp slt i64 undef, undef 144 ret i1 %r 145 } 146 147 define i1 @test15() { 148 ; CHECK-LABEL: @test15( 149 ; CHECK: ret i1 undef 150 ; 151 %r = icmp ult i64 undef, undef 152 ret i1 %r 153 } 154 155 define i64 @test16(i64 %a) { 156 ; CHECK-LABEL: @test16( 157 ; CHECK: ret i64 undef 158 ; 159 %r = select i1 undef, i64 %a, i64 undef 160 ret i64 %r 161 } 162 163 define i64 @test17(i64 %a) { 164 ; CHECK-LABEL: @test17( 165 ; CHECK: ret i64 undef 166 ; 167 %r = select i1 undef, i64 undef, i64 %a 168 ret i64 %r 169 } 170 171 define i64 @test18(i64 %a) { 172 ; CHECK-LABEL: @test18( 173 ; CHECK: [[R:%.*]] = call i64 undef(i64 %a) 174 ; CHECK-NEXT: ret i64 undef 175 ; 176 %r = call i64 (i64) undef(i64 %a) 177 ret i64 %r 178 } 179 180 define <4 x i8> @test19(<4 x i8> %a) { 181 ; CHECK-LABEL: @test19( 182 ; CHECK: ret <4 x i8> undef 183 ; 184 %b = shl <4 x i8> %a, <i8 8, i8 9, i8 undef, i8 -1> 185 ret <4 x i8> %b 186 } 187 188 define i32 @test20(i32 %a) { 189 ; CHECK-LABEL: @test20( 190 ; CHECK: ret i32 undef 191 ; 192 %b = udiv i32 %a, 0 193 ret i32 %b 194 } 195 196 define <2 x i32> @test20vec(<2 x i32> %a) { 197 ; CHECK-LABEL: @test20vec( 198 ; CHECK-NEXT: ret <2 x i32> undef 199 ; 200 %b = udiv <2 x i32> %a, zeroinitializer 201 ret <2 x i32> %b 202 } 203 204 define i32 @test21(i32 %a) { 205 ; CHECK-LABEL: @test21( 206 ; CHECK: ret i32 undef 207 ; 208 %b = sdiv i32 %a, 0 209 ret i32 %b 210 } 211 212 define <2 x i32> @test21vec(<2 x i32> %a) { 213 ; CHECK-LABEL: @test21vec( 214 ; CHECK-NEXT: ret <2 x i32> undef 215 ; 216 %b = sdiv <2 x i32> %a, zeroinitializer 217 ret <2 x i32> %b 218 } 219 220 define i32 @test22(i32 %a) { 221 ; CHECK-LABEL: @test22( 222 ; CHECK: ret i32 undef 223 ; 224 %b = ashr exact i32 undef, %a 225 ret i32 %b 226 } 227 228 define i32 @test23(i32 %a) { 229 ; CHECK-LABEL: @test23( 230 ; CHECK: ret i32 undef 231 ; 232 %b = lshr exact i32 undef, %a 233 ret i32 %b 234 } 235 236 define i32 @test24() { 237 ; CHECK-LABEL: @test24( 238 ; CHECK: ret i32 undef 239 ; 240 %b = udiv i32 undef, 0 241 ret i32 %b 242 } 243 244 define i32 @test25() { 245 ; CHECK-LABEL: @test25( 246 ; CHECK: ret i32 undef 247 ; 248 %b = lshr i32 0, undef 249 ret i32 %b 250 } 251 252 define i32 @test26() { 253 ; CHECK-LABEL: @test26( 254 ; CHECK: ret i32 undef 255 ; 256 %b = ashr i32 0, undef 257 ret i32 %b 258 } 259 260 define i32 @test27() { 261 ; CHECK-LABEL: @test27( 262 ; CHECK: ret i32 undef 263 ; 264 %b = shl i32 0, undef 265 ret i32 %b 266 } 267 268 define i32 @test28(i32 %a) { 269 ; CHECK-LABEL: @test28( 270 ; CHECK: ret i32 undef 271 ; 272 %b = shl nsw i32 undef, %a 273 ret i32 %b 274 } 275 276 define i32 @test29(i32 %a) { 277 ; CHECK-LABEL: @test29( 278 ; CHECK: ret i32 undef 279 ; 280 %b = shl nuw i32 undef, %a 281 ret i32 %b 282 } 283 284 define i32 @test30(i32 %a) { 285 ; CHECK-LABEL: @test30( 286 ; CHECK: ret i32 undef 287 ; 288 %b = shl nsw nuw i32 undef, %a 289 ret i32 %b 290 } 291 292 define i32 @test31(i32 %a) { 293 ; CHECK-LABEL: @test31( 294 ; CHECK: ret i32 0 295 ; 296 %b = shl i32 undef, %a 297 ret i32 %b 298 } 299 300 define i32 @test32(i32 %a) { 301 ; CHECK-LABEL: @test32( 302 ; CHECK: ret i32 undef 303 ; 304 %b = shl i32 undef, 0 305 ret i32 %b 306 } 307 308 define i32 @test33(i32 %a) { 309 ; CHECK-LABEL: @test33( 310 ; CHECK: ret i32 undef 311 ; 312 %b = ashr i32 undef, 0 313 ret i32 %b 314 } 315 316 define i32 @test34(i32 %a) { 317 ; CHECK-LABEL: @test34( 318 ; CHECK: ret i32 undef 319 ; 320 %b = lshr i32 undef, 0 321 ret i32 %b 322 } 323 324 define i32 @test35(<4 x i32> %V) { 325 ; CHECK-LABEL: @test35( 326 ; CHECK: ret i32 undef 327 ; 328 %b = extractelement <4 x i32> %V, i32 4 329 ret i32 %b 330 } 331 332 define i32 @test36(i32 %V) { 333 ; CHECK-LABEL: @test36( 334 ; CHECK: ret i32 undef 335 ; 336 %b = extractelement <4 x i32> undef, i32 %V 337 ret i32 %b 338 } 339 340 define i32 @test37() { 341 ; CHECK-LABEL: @test37( 342 ; CHECK: ret i32 undef 343 ; 344 %b = udiv i32 undef, undef 345 ret i32 %b 346 } 347 348 define i32 @test38(i32 %a) { 349 ; CHECK-LABEL: @test38( 350 ; CHECK: ret i32 undef 351 ; 352 %b = udiv i32 %a, undef 353 ret i32 %b 354 } 355 356 define i32 @test39() { 357 ; CHECK-LABEL: @test39( 358 ; CHECK: ret i32 undef 359 ; 360 %b = udiv i32 0, undef 361 ret i32 %b 362 } 363