439 lines · plain
1; NOTE: This test case is borrowed from undef-ops.ll2; RUN: llc < %s -mtriple=x86_64-unknown-unknown | FileCheck %s3 4define i32 @add_poison_rhs(i32 %x) {5; CHECK-LABEL: add_poison_rhs:6; CHECK: # %bb.0:7; CHECK-NEXT: retq8 %r = add i32 %x, poison9 ret i32 %r10}11 12define <4 x i32> @add_poison_rhs_vec(<4 x i32> %x) {13; CHECK-LABEL: add_poison_rhs_vec:14; CHECK: # %bb.0:15; CHECK-NEXT: retq16 %r = add <4 x i32> %x, poison17 ret <4 x i32> %r18}19 20define i32 @add_poison_lhs(i32 %x) {21; CHECK-LABEL: add_poison_lhs:22; CHECK: # %bb.0:23; CHECK-NEXT: retq24 %r = add i32 poison, %x25 ret i32 %r26}27 28define <4 x i32> @add_poison_lhs_vec(<4 x i32> %x) {29; CHECK-LABEL: add_poison_lhs_vec:30; CHECK: # %bb.0:31; CHECK-NEXT: retq32 %r = add <4 x i32> poison, %x33 ret <4 x i32> %r34}35 36define i32 @sub_poison_rhs(i32 %x) {37; CHECK-LABEL: sub_poison_rhs:38; CHECK: # %bb.0:39; CHECK-NEXT: retq40 %r = sub i32 %x, poison41 ret i32 %r42}43 44define <4 x i32> @sub_poison_rhs_vec(<4 x i32> %x) {45; CHECK-LABEL: sub_poison_rhs_vec:46; CHECK: # %bb.0:47; CHECK-NEXT: retq48 %r = sub <4 x i32> %x, poison49 ret <4 x i32> %r50}51 52define i32 @sub_poison_lhs(i32 %x) {53; CHECK-LABEL: sub_poison_lhs:54; CHECK: # %bb.0:55; CHECK-NEXT: retq56 %r = sub i32 poison, %x57 ret i32 %r58}59 60define <4 x i32> @sub_poison_lhs_vec(<4 x i32> %x) {61; CHECK-LABEL: sub_poison_lhs_vec:62; CHECK: # %bb.0:63; CHECK-NEXT: retq64 %r = sub <4 x i32> poison, %x65 ret <4 x i32> %r66}67 68define i32 @mul_poison_rhs(i32 %x) {69; CHECK-LABEL: mul_poison_rhs:70; CHECK: # %bb.0:71; CHECK-NEXT: retq72 %r = mul i32 %x, poison73 ret i32 %r74}75 76define <4 x i32> @mul_poison_rhs_vec(<4 x i32> %x) {77; CHECK-LABEL: mul_poison_rhs_vec:78; CHECK: # %bb.0:79; CHECK-NEXT: retq80 %r = mul <4 x i32> %x, poison81 ret <4 x i32> %r82}83 84define i32 @mul_poison_lhs(i32 %x) {85; CHECK-LABEL: mul_poison_lhs:86; CHECK: # %bb.0:87; CHECK-NEXT: retq88 %r = mul i32 poison, %x89 ret i32 %r90}91 92define <4 x i32> @mul_poison_lhs_vec(<4 x i32> %x) {93; CHECK-LABEL: mul_poison_lhs_vec:94; CHECK: # %bb.0:95; CHECK-NEXT: retq96 %r = mul <4 x i32> poison, %x97 ret <4 x i32> %r98}99 100define i32 @sdiv_poison_rhs(i32 %x) {101; CHECK-LABEL: sdiv_poison_rhs:102; CHECK: # %bb.0:103; CHECK-NEXT: retq104 %r = sdiv i32 %x, poison105 ret i32 %r106}107 108define <4 x i32> @sdiv_poison_rhs_vec(<4 x i32> %x) {109; CHECK-LABEL: sdiv_poison_rhs_vec:110; CHECK: # %bb.0:111; CHECK-NEXT: retq112 %r = sdiv <4 x i32> %x, poison113 ret <4 x i32> %r114}115 116define i32 @sdiv_poison_lhs(i32 %x) {117; CHECK-LABEL: sdiv_poison_lhs:118; CHECK: # %bb.0:119; CHECK-NEXT: retq120 %r = sdiv i32 poison, %x121 ret i32 %r122}123 124define <4 x i32> @sdiv_poison_lhs_vec(<4 x i32> %x) {125; CHECK-LABEL: sdiv_poison_lhs_vec:126; CHECK: # %bb.0:127; CHECK-NEXT: retq128 %r = sdiv <4 x i32> poison, %x129 ret <4 x i32> %r130}131 132define i32 @udiv_poison_rhs(i32 %x) {133; CHECK-LABEL: udiv_poison_rhs:134; CHECK: # %bb.0:135; CHECK-NEXT: retq136 %r = udiv i32 %x, poison137 ret i32 %r138}139 140define <4 x i32> @udiv_poison_rhs_vec(<4 x i32> %x) {141; CHECK-LABEL: udiv_poison_rhs_vec:142; CHECK: # %bb.0:143; CHECK-NEXT: retq144 %r = udiv <4 x i32> %x, poison145 ret <4 x i32> %r146}147 148define i32 @udiv_poison_lhs(i32 %x) {149; CHECK-LABEL: udiv_poison_lhs:150; CHECK: # %bb.0:151; CHECK-NEXT: retq152 %r = udiv i32 poison, %x153 ret i32 %r154}155 156define <4 x i32> @udiv_poison_lhs_vec(<4 x i32> %x) {157; CHECK-LABEL: udiv_poison_lhs_vec:158; CHECK: # %bb.0:159; CHECK-NEXT: retq160 %r = udiv <4 x i32> poison, %x161 ret <4 x i32> %r162}163 164define i32 @srem_poison_rhs(i32 %x) {165; CHECK-LABEL: srem_poison_rhs:166; CHECK: # %bb.0:167; CHECK-NEXT: retq168 %r = srem i32 %x, poison169 ret i32 %r170}171 172define <4 x i32> @srem_poison_rhs_vec(<4 x i32> %x) {173; CHECK-LABEL: srem_poison_rhs_vec:174; CHECK: # %bb.0:175; CHECK-NEXT: retq176 %r = srem <4 x i32> %x, poison177 ret <4 x i32> %r178}179 180define i32 @srem_poison_lhs(i32 %x) {181; CHECK-LABEL: srem_poison_lhs:182; CHECK: # %bb.0:183; CHECK-NEXT: retq184 %r = srem i32 poison, %x185 ret i32 %r186}187 188define <4 x i32> @srem_poison_lhs_vec(<4 x i32> %x) {189; CHECK-LABEL: srem_poison_lhs_vec:190; CHECK: # %bb.0:191; CHECK-NEXT: retq192 %r = srem <4 x i32> poison, %x193 ret <4 x i32> %r194}195 196define i32 @urem_poison_rhs(i32 %x) {197; CHECK-LABEL: urem_poison_rhs:198; CHECK: # %bb.0:199; CHECK-NEXT: retq200 %r = urem i32 %x, poison201 ret i32 %r202}203 204define <4 x i32> @urem_poison_rhs_vec(<4 x i32> %x) {205; CHECK-LABEL: urem_poison_rhs_vec:206; CHECK: # %bb.0:207; CHECK-NEXT: retq208 %r = urem <4 x i32> %x, poison209 ret <4 x i32> %r210}211 212define i32 @urem_poison_lhs(i32 %x) {213; CHECK-LABEL: urem_poison_lhs:214; CHECK: # %bb.0:215; CHECK-NEXT: retq216 %r = urem i32 poison, %x217 ret i32 %r218}219 220define <4 x i32> @urem_poison_lhs_vec(<4 x i32> %x) {221; CHECK-LABEL: urem_poison_lhs_vec:222; CHECK: # %bb.0:223; CHECK-NEXT: retq224 %r = urem <4 x i32> poison, %x225 ret <4 x i32> %r226}227 228define i32 @ashr_poison_rhs(i32 %x) {229; CHECK-LABEL: ashr_poison_rhs:230; CHECK: # %bb.0:231; CHECK-NEXT: retq232 %r = ashr i32 %x, poison233 ret i32 %r234}235 236define <4 x i32> @ashr_poison_rhs_vec(<4 x i32> %x) {237; CHECK-LABEL: ashr_poison_rhs_vec:238; CHECK: # %bb.0:239; CHECK-NEXT: retq240 %r = ashr <4 x i32> %x, poison241 ret <4 x i32> %r242}243 244define i32 @ashr_poison_lhs(i32 %x) {245; CHECK-LABEL: ashr_poison_lhs:246; CHECK: # %bb.0:247; CHECK-NEXT: xorl %eax, %eax248; CHECK-NEXT: retq249 %r = ashr i32 poison, %x250 ret i32 %r251}252 253define <4 x i32> @ashr_poison_lhs_vec(<4 x i32> %x) {254; CHECK-LABEL: ashr_poison_lhs_vec:255; CHECK: # %bb.0:256; CHECK-NEXT: xorps %xmm0, %xmm0257; CHECK-NEXT: retq258 %r = ashr <4 x i32> poison, %x259 ret <4 x i32> %r260}261 262define i32 @lshr_poison_rhs(i32 %x) {263; CHECK-LABEL: lshr_poison_rhs:264; CHECK: # %bb.0:265; CHECK-NEXT: retq266 %r = lshr i32 %x, poison267 ret i32 %r268}269 270define <4 x i32> @lshr_poison_rhs_vec(<4 x i32> %x) {271; CHECK-LABEL: lshr_poison_rhs_vec:272; CHECK: # %bb.0:273; CHECK-NEXT: retq274 %r = lshr <4 x i32> %x, poison275 ret <4 x i32> %r276}277 278define i32 @lshr_poison_lhs(i32 %x) {279; CHECK-LABEL: lshr_poison_lhs:280; CHECK: # %bb.0:281; CHECK-NEXT: xorl %eax, %eax282; CHECK-NEXT: retq283 %r = lshr i32 poison, %x284 ret i32 %r285}286 287define <4 x i32> @lshr_poison_lhs_vec(<4 x i32> %x) {288; CHECK-LABEL: lshr_poison_lhs_vec:289; CHECK: # %bb.0:290; CHECK-NEXT: xorps %xmm0, %xmm0291; CHECK-NEXT: retq292 %r = lshr <4 x i32> poison, %x293 ret <4 x i32> %r294}295 296define i32 @shl_poison_rhs(i32 %x) {297; CHECK-LABEL: shl_poison_rhs:298; CHECK: # %bb.0:299; CHECK-NEXT: retq300 %r = shl i32 %x, poison301 ret i32 %r302}303 304define <4 x i32> @shl_poison_rhs_vec(<4 x i32> %x) {305; CHECK-LABEL: shl_poison_rhs_vec:306; CHECK: # %bb.0:307; CHECK-NEXT: retq308 %r = shl <4 x i32> %x, poison309 ret <4 x i32> %r310}311 312define i32 @shl_poison_lhs(i32 %x) {313; CHECK-LABEL: shl_poison_lhs:314; CHECK: # %bb.0:315; CHECK-NEXT: xorl %eax, %eax316; CHECK-NEXT: retq317 %r = shl i32 poison, %x318 ret i32 %r319}320 321define <4 x i32> @shl_poison_lhs_vec(<4 x i32> %x) {322; CHECK-LABEL: shl_poison_lhs_vec:323; CHECK: # %bb.0:324; CHECK-NEXT: xorps %xmm0, %xmm0325; CHECK-NEXT: retq326 %r = shl <4 x i32> poison, %x327 ret <4 x i32> %r328}329 330define i32 @and_poison_rhs(i32 %x) {331; CHECK-LABEL: and_poison_rhs:332; CHECK: # %bb.0:333; CHECK-NEXT: retq334 %r = and i32 %x, poison335 ret i32 %r336}337 338define <4 x i32> @and_poison_rhs_vec(<4 x i32> %x) {339; CHECK-LABEL: and_poison_rhs_vec:340; CHECK: # %bb.0:341; CHECK-NEXT: retq342 %r = and <4 x i32> %x, poison343 ret <4 x i32> %r344}345 346define i32 @and_poison_lhs(i32 %x) {347; CHECK-LABEL: and_poison_lhs:348; CHECK: # %bb.0:349; CHECK-NEXT: retq350 %r = and i32 poison, %x351 ret i32 %r352}353 354define <4 x i32> @and_poison_lhs_vec(<4 x i32> %x) {355; CHECK-LABEL: and_poison_lhs_vec:356; CHECK: # %bb.0:357; CHECK-NEXT: retq358 %r = and <4 x i32> poison, %x359 ret <4 x i32> %r360}361 362define i32 @or_poison_rhs(i32 %x) {363; CHECK-LABEL: or_poison_rhs:364; CHECK: # %bb.0:365; CHECK-NEXT: retq366 %r = or i32 %x, poison367 ret i32 %r368}369 370define <4 x i32> @or_poison_rhs_vec(<4 x i32> %x) {371; CHECK-LABEL: or_poison_rhs_vec:372; CHECK: # %bb.0:373; CHECK-NEXT: retq374 %r = or <4 x i32> %x, poison375 ret <4 x i32> %r376}377 378define i32 @or_poison_lhs(i32 %x) {379; CHECK-LABEL: or_poison_lhs:380; CHECK: # %bb.0:381; CHECK-NEXT: retq382 %r = or i32 poison, %x383 ret i32 %r384}385 386define <4 x i32> @or_poison_lhs_vec(<4 x i32> %x) {387; CHECK-LABEL: or_poison_lhs_vec:388; CHECK: # %bb.0:389; CHECK-NEXT: retq390 %r = or <4 x i32> poison, %x391 ret <4 x i32> %r392}393 394define i32 @xor_poison_rhs(i32 %x) {395; CHECK-LABEL: xor_poison_rhs:396; CHECK: # %bb.0:397; CHECK-NEXT: retq398 %r = xor i32 %x, poison399 ret i32 %r400}401 402define <4 x i32> @xor_poison_rhs_vec(<4 x i32> %x) {403; CHECK-LABEL: xor_poison_rhs_vec:404; CHECK: # %bb.0:405; CHECK-NEXT: retq406 %r = xor <4 x i32> %x, poison407 ret <4 x i32> %r408}409 410define i32 @xor_poison_lhs(i32 %x) {411; CHECK-LABEL: xor_poison_lhs:412; CHECK: # %bb.0:413; CHECK-NEXT: retq414 %r = xor i32 poison, %x415 ret i32 %r416}417 418define <4 x i32> @xor_poison_lhs_vec(<4 x i32> %x) {419; CHECK-LABEL: xor_poison_lhs_vec:420; CHECK: # %bb.0:421; CHECK-NEXT: retq422 %r = xor <4 x i32> poison, %x423 ret <4 x i32> %r424}425 426; This would crash because the shift amount is an i8 operand,427; but the result of the shift is i32. We can't just propagate428; the existing poison as the result.429 430define i1 @poison_operand_size_not_same_as_result() {431; CHECK-LABEL: poison_operand_size_not_same_as_result:432; CHECK: # %bb.0:433; CHECK-NEXT: retq434 %sh = shl i32 7, poison435 %cmp = icmp eq i32 0, %sh436 ret i1 %cmp437}438 439