Skip to content
This repository was archived by the owner on Apr 23, 2020. It is now read-only.

Commit 151fce6

Browse files
committed
[InstSimplify] add tests for or-of-casted-icmps; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302174 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 316966e commit 151fce6

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

test/Transforms/InstSimplify/AndOrXor.ll

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,64 @@ define <2 x i3> @and_of_different_cast_icmps_vec(<2 x i8> %i, <2 x i16> %j) {
468468
ret <2 x i3> %and
469469
}
470470

471+
; FIXME: This should simplify.
472+
473+
define i32 @or_of_zexted_icmps(i32 %i) {
474+
; CHECK-LABEL: @or_of_zexted_icmps(
475+
; CHECK-NEXT: [[CMP0:%.*]] = icmp ne i32 %i, 0
476+
; CHECK-NEXT: [[CONV0:%.*]] = zext i1 [[CMP0]] to i32
477+
; CHECK-NEXT: [[CMP1:%.*]] = icmp uge i32 4, %i
478+
; CHECK-NEXT: [[CONV1:%.*]] = zext i1 [[CMP1]] to i32
479+
; CHECK-NEXT: [[OR:%.*]] = or i32 [[CONV0]], [[CONV1]]
480+
; CHECK-NEXT: ret i32 [[OR]]
481+
;
482+
%cmp0 = icmp ne i32 %i, 0
483+
%conv0 = zext i1 %cmp0 to i32
484+
%cmp1 = icmp uge i32 4, %i
485+
%conv1 = zext i1 %cmp1 to i32
486+
%or = or i32 %conv0, %conv1
487+
ret i32 %or
488+
}
489+
490+
; FIXME: This should simplify
491+
; Try a different cast and weird vector types.
492+
493+
define i3 @or_of_bitcast_icmps_vec(<3 x i65> %i) {
494+
; CHECK-LABEL: @or_of_bitcast_icmps_vec(
495+
; CHECK-NEXT: [[CMP0:%.*]] = icmp sge <3 x i65> %i, zeroinitializer
496+
; CHECK-NEXT: [[CONV0:%.*]] = bitcast <3 x i1> [[CMP0]] to i3
497+
; CHECK-NEXT: [[CMP1:%.*]] = icmp slt <3 x i65> %i, zeroinitializer
498+
; CHECK-NEXT: [[CONV1:%.*]] = bitcast <3 x i1> [[CMP1]] to i3
499+
; CHECK-NEXT: [[OR:%.*]] = or i3 [[CONV0]], [[CONV1]]
500+
; CHECK-NEXT: ret i3 [[OR]]
501+
;
502+
%cmp0 = icmp sge <3 x i65> %i, zeroinitializer
503+
%conv0 = bitcast <3 x i1> %cmp0 to i3
504+
%cmp1 = icmp slt <3 x i65> %i, zeroinitializer
505+
%conv1 = bitcast <3 x i1> %cmp1 to i3
506+
%or = or i3 %conv0, %conv1
507+
ret i3 %or
508+
}
509+
510+
; We can't simplify if the casts are different.
511+
512+
define i16 @or_of_different_cast_icmps(i8 %i) {
513+
; CHECK-LABEL: @or_of_different_cast_icmps(
514+
; CHECK-NEXT: [[CMP0:%.*]] = icmp ne i8 %i, 0
515+
; CHECK-NEXT: [[CONV0:%.*]] = zext i1 [[CMP0]] to i16
516+
; CHECK-NEXT: [[CMP1:%.*]] = icmp ne i8 %i, 1
517+
; CHECK-NEXT: [[CONV1:%.*]] = sext i1 [[CMP1]] to i16
518+
; CHECK-NEXT: [[OR:%.*]] = or i16 [[CONV0]], [[CONV1]]
519+
; CHECK-NEXT: ret i16 [[OR]]
520+
;
521+
%cmp0 = icmp ne i8 %i, 0
522+
%conv0 = zext i1 %cmp0 to i16
523+
%cmp1 = icmp ne i8 %i, 1
524+
%conv1 = sext i1 %cmp1 to i16
525+
%or = or i16 %conv0, %conv1
526+
ret i16 %or
527+
}
528+
471529
; (A & ~B) | (A ^ B) -> A ^ B
472530

473531
define i32 @test43(i32 %a, i32 %b) {

0 commit comments

Comments
 (0)