@@ -437,14 +437,17 @@ define i8 @t17_oneuse(i8 %x) {
437
437
ret i8 %x.roundedup
438
438
}
439
439
440
- ; Bias is equal to the alignment-1 (as opposed to alignment),
441
- ; so we can just replace %x.roundedup with %x.biased.highbits
440
+ ; Negative test: We can't replace with %x.biased.highbits because it is
441
+ ; more poisonous.
442
442
define <2 x i4 > @t18_replacement_0b0001 (<2 x i4 > %x ) {
443
443
; CHECK-LABEL: @t18_replacement_0b0001(
444
- ; CHECK-NEXT: [[X_BIASED:%.*]] = add <2 x i4> [[X:%.*]], <i4 3, i4 3>
444
+ ; CHECK-NEXT: [[X_LOWBITS:%.*]] = and <2 x i4> [[X:%.*]], <i4 3, i4 3>
445
+ ; CHECK-NEXT: [[X_LOWBITS_ARE_ZERO:%.*]] = icmp eq <2 x i4> [[X_LOWBITS]], zeroinitializer
446
+ ; CHECK-NEXT: [[X_BIASED:%.*]] = add <2 x i4> [[X]], <i4 3, i4 3>
445
447
; CHECK-NEXT: [[X_BIASED_HIGHBITS:%.*]] = and <2 x i4> [[X_BIASED]], <i4 -4, i4 poison>
446
448
; CHECK-NEXT: call void @use.v2i4(<2 x i4> [[X_BIASED_HIGHBITS]])
447
- ; CHECK-NEXT: ret <2 x i4> [[X_BIASED_HIGHBITS]]
449
+ ; CHECK-NEXT: [[X_ROUNDEDUP:%.*]] = select <2 x i1> [[X_LOWBITS_ARE_ZERO]], <2 x i4> [[X]], <2 x i4> [[X_BIASED_HIGHBITS]]
450
+ ; CHECK-NEXT: ret <2 x i4> [[X_ROUNDEDUP]]
448
451
;
449
452
%x.lowbits = and <2 x i4 > %x , <i4 3 , i4 3 >
450
453
%x.lowbits.are.zero = icmp eq <2 x i4 > %x.lowbits , <i4 0 , i4 0 >
@@ -454,12 +457,17 @@ define <2 x i4> @t18_replacement_0b0001(<2 x i4> %x) {
454
457
%x.roundedup = select <2 x i1 > %x.lowbits.are.zero , <2 x i4 > %x , <2 x i4 > %x.biased.highbits
455
458
ret <2 x i4 > %x.roundedup
456
459
}
460
+ ; Negative test: We can't replace with %x.biased.highbits because it is
461
+ ; more poisonous.
457
462
define <2 x i4 > @t18_replacement_0b0010 (<2 x i4 > %x ) {
458
463
; CHECK-LABEL: @t18_replacement_0b0010(
459
- ; CHECK-NEXT: [[X_BIASED:%.*]] = add <2 x i4> [[X:%.*]], <i4 3, i4 poison>
464
+ ; CHECK-NEXT: [[X_LOWBITS:%.*]] = and <2 x i4> [[X:%.*]], <i4 3, i4 3>
465
+ ; CHECK-NEXT: [[X_LOWBITS_ARE_ZERO:%.*]] = icmp eq <2 x i4> [[X_LOWBITS]], zeroinitializer
466
+ ; CHECK-NEXT: [[X_BIASED:%.*]] = add <2 x i4> [[X]], <i4 3, i4 poison>
460
467
; CHECK-NEXT: [[X_BIASED_HIGHBITS:%.*]] = and <2 x i4> [[X_BIASED]], <i4 -4, i4 -4>
461
468
; CHECK-NEXT: call void @use.v2i4(<2 x i4> [[X_BIASED_HIGHBITS]])
462
- ; CHECK-NEXT: ret <2 x i4> [[X_BIASED_HIGHBITS]]
469
+ ; CHECK-NEXT: [[X_ROUNDEDUP:%.*]] = select <2 x i1> [[X_LOWBITS_ARE_ZERO]], <2 x i4> [[X]], <2 x i4> [[X_BIASED_HIGHBITS]]
470
+ ; CHECK-NEXT: ret <2 x i4> [[X_ROUNDEDUP]]
463
471
;
464
472
%x.lowbits = and <2 x i4 > %x , <i4 3 , i4 3 >
465
473
%x.lowbits.are.zero = icmp eq <2 x i4 > %x.lowbits , <i4 0 , i4 0 >
0 commit comments