[InstCombine] add tests for freeze of partial undef vector constants; NFC
authorSanjay Patel <spatel@rotateright.com>
Mon, 18 Apr 2022 20:45:25 +0000 (16:45 -0400)
committerSanjay Patel <spatel@rotateright.com>
Tue, 19 Apr 2022 16:41:50 +0000 (12:41 -0400)
llvm/test/Transforms/InstCombine/freeze.ll
llvm/test/Transforms/InstCombine/select.ll

index 9f2c47c..3fee57a 100644 (file)
@@ -87,6 +87,15 @@ define void @or_select_multipleuses_logical(i32 %x, i1 %y) {
   ret void
 }
 
+define <3 x i4> @partial_undef_vec() {
+; CHECK-LABEL: @partial_undef_vec(
+; CHECK-NEXT:    [[F:%.*]] = freeze <3 x i4> <i4 poison, i4 1, i4 undef>
+; CHECK-NEXT:    ret <3 x i4> [[F]]
+;
+  %f = freeze <3 x i4> <i4 poison, i4 1, i4 undef>
+  ret <3 x i4> %f
+}
+
 ; Move the freeze forward to prevent poison from spreading.
 
 define i32 @early_freeze_test1(i32 %x, i32 %y) {
@@ -267,8 +276,8 @@ define i32 @propagate_drop_flags_mul(i32 %arg) {
 define i32 @propagate_drop_flags_udiv(i32 %arg) {
 ; CHECK-LABEL: @propagate_drop_flags_udiv(
 ; CHECK-NEXT:    [[ARG_FR:%.*]] = freeze i32 [[ARG:%.*]]
-; CHECK-NEXT:    [[V1:%.*]] = lshr i32 [[ARG_FR]], 1
-; CHECK-NEXT:    ret i32 [[V1]]
+; CHECK-NEXT:    [[V11:%.*]] = lshr i32 [[ARG_FR]], 1
+; CHECK-NEXT:    ret i32 [[V11]]
 ;
   %v1 = udiv exact i32 %arg, 2
   %v1.fr = freeze i32 %v1
index 1705913..e68c8e5 100644 (file)
@@ -2642,6 +2642,28 @@ define <2 x i8> @partial_cond_freeze_constant_true_val_vec(<2 x i8> %x) {
   ret <2 x i8> %s
 }
 
+define <2 x i8> @partial_cond_freeze_constant_false_val_vec(<2 x i8> %x) {
+; CHECK-LABEL: @partial_cond_freeze_constant_false_val_vec(
+; CHECK-NEXT:    [[COND_FR:%.*]] = freeze <2 x i1> <i1 true, i1 undef>
+; CHECK-NEXT:    [[S:%.*]] = select <2 x i1> [[COND_FR]], <2 x i8> [[X:%.*]], <2 x i8> <i8 1, i8 2>
+; CHECK-NEXT:    ret <2 x i8> [[S]]
+;
+  %cond.fr = freeze <2 x i1> <i1 true, i1 undef>
+  %s = select <2 x i1> %cond.fr, <2 x i8> %x, <2 x i8> <i8 1, i8 2>
+  ret <2 x i8> %s
+}
+
+define <2 x i8> @partial_cond_freeze_both_arms_constant_vec() {
+; CHECK-LABEL: @partial_cond_freeze_both_arms_constant_vec(
+; CHECK-NEXT:    [[COND_FR:%.*]] = freeze <2 x i1> <i1 false, i1 undef>
+; CHECK-NEXT:    [[S:%.*]] = select <2 x i1> [[COND_FR]], <2 x i8> <i8 1, i8 2>, <2 x i8> <i8 42, i8 43>
+; CHECK-NEXT:    ret <2 x i8> [[S]]
+;
+  %cond.fr = freeze <2 x i1> <i1 false, i1 undef>
+  %s = select <2 x i1> %cond.fr, <2 x i8> <i8 1, i8 2>, <2 x i8> <i8 42, i8 43>
+  ret <2 x i8> %s
+}
+
 declare void @foo2(i8, i8)
 
 define void @cond_freeze_multipleuses(i8 %x, i8 %y) {