[llvm] 3237497 - [Vectorize] Pre-commit tests for D148905

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 24 05:42:21 PDT 2023


Author: Jay Foad
Date: 2023-04-24T13:42:08+01:00
New Revision: 3237497d01e8b34039f2b0d160077f09765a0e29

URL: https://github.com/llvm/llvm-project/commit/3237497d01e8b34039f2b0d160077f09765a0e29
DIFF: https://github.com/llvm/llvm-project/commit/3237497d01e8b34039f2b0d160077f09765a0e29.diff

LOG: [Vectorize] Pre-commit tests for D148905

Differential Revision: https://reviews.llvm.org/D149050

Added: 
    llvm/test/Transforms/LoopVectorize/is_fpclass.ll
    llvm/test/Transforms/SLPVectorizer/is_fpclass.ll

Modified: 
    llvm/test/Transforms/Scalarizer/intrinsics.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/LoopVectorize/is_fpclass.ll b/llvm/test/Transforms/LoopVectorize/is_fpclass.ll
new file mode 100644
index 0000000000000..955b1b862f149
--- /dev/null
+++ b/llvm/test/Transforms/LoopVectorize/is_fpclass.ll
@@ -0,0 +1,39 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
+; RUN: opt < %s -passes=loop-vectorize -force-vector-width=2 -S | FileCheck %s
+
+define void @d() {
+; CHECK-LABEL: define void @d() {
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:    br label [[LOOP:%.*]]
+; CHECK:       loop:
+; CHECK-NEXT:    [[I:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[I7:%.*]], [[LOOP]] ]
+; CHECK-NEXT:    [[I3:%.*]] = load float, ptr null, align 4
+; CHECK-NEXT:    [[I4:%.*]] = getelementptr float, ptr @d, i64 [[I]]
+; CHECK-NEXT:    [[I5:%.*]] = tail call i1 @llvm.is.fpclass.f32(float 0.000000e+00, i32 0)
+; CHECK-NEXT:    [[I6:%.*]] = select i1 [[I5]], float 0.000000e+00, float 0.000000e+00
+; CHECK-NEXT:    store float [[I6]], ptr [[I4]], align 4
+; CHECK-NEXT:    [[I7]] = add i64 [[I]], 1
+; CHECK-NEXT:    [[I8:%.*]] = icmp eq i64 [[I7]], 0
+; CHECK-NEXT:    br i1 [[I8]], label [[EXIT:%.*]], label [[LOOP]]
+; CHECK:       exit:
+; CHECK-NEXT:    ret void
+;
+entry:
+  br label %loop
+
+loop:
+  %i = phi i64 [ 0, %entry ], [ %i7, %loop ]
+  %i3 = load float, ptr null, align 4
+  %i4 = getelementptr float, ptr @d, i64 %i
+  %i5 = tail call i1 @llvm.is.fpclass.f32(float 0.0, i32 0)
+  %i6 = select i1 %i5, float 0.0, float 0.0
+  store float %i6, ptr %i4, align 4
+  %i7 = add i64 %i, 1
+  %i8 = icmp eq i64 %i7, 0
+  br i1 %i8, label %exit, label %loop
+
+exit:
+  ret void
+}
+
+declare i1 @llvm.is.fpclass.f32(float, i32 immarg)

diff  --git a/llvm/test/Transforms/SLPVectorizer/is_fpclass.ll b/llvm/test/Transforms/SLPVectorizer/is_fpclass.ll
new file mode 100644
index 0000000000000..2bb5c347b8152
--- /dev/null
+++ b/llvm/test/Transforms/SLPVectorizer/is_fpclass.ll
@@ -0,0 +1,24 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
+; RUN: opt -S -passes=slp-vectorizer < %s | FileCheck %s
+
+define <2 x i1> @scalarize_is_fpclass(<2 x float> %x) {
+; CHECK-LABEL: define <2 x i1> @scalarize_is_fpclass
+; CHECK-SAME: (<2 x float> [[X:%.*]]) {
+; CHECK-NEXT:    [[X_I0:%.*]] = extractelement <2 x float> [[X]], i32 0
+; CHECK-NEXT:    [[ISFPCLASS_I0:%.*]] = call i1 @llvm.is.fpclass.f32(float [[X_I0]], i32 123)
+; CHECK-NEXT:    [[X_I1:%.*]] = extractelement <2 x float> [[X]], i32 1
+; CHECK-NEXT:    [[ISFPCLASS_I1:%.*]] = call i1 @llvm.is.fpclass.f32(float [[X_I1]], i32 123)
+; CHECK-NEXT:    [[ISFPCLASS_UPTO0:%.*]] = insertelement <2 x i1> poison, i1 [[ISFPCLASS_I0]], i32 0
+; CHECK-NEXT:    [[ISFPCLASS:%.*]] = insertelement <2 x i1> [[ISFPCLASS_UPTO0]], i1 [[ISFPCLASS_I1]], i32 1
+; CHECK-NEXT:    ret <2 x i1> [[ISFPCLASS]]
+;
+  %x.i0 = extractelement <2 x float> %x, i32 0
+  %isfpclass.i0 = call i1 @llvm.is.fpclass.f32(float %x.i0, i32 123)
+  %x.i1 = extractelement <2 x float> %x, i32 1
+  %isfpclass.i1 = call i1 @llvm.is.fpclass.f32(float %x.i1, i32 123)
+  %isfpclass.upto0 = insertelement <2 x i1> poison, i1 %isfpclass.i0, i32 0
+  %isfpclass = insertelement <2 x i1> %isfpclass.upto0, i1 %isfpclass.i1, i32 1
+  ret <2 x i1> %isfpclass
+}
+
+declare i1 @llvm.is.fpclass.f32(float, i32 immarg)

diff  --git a/llvm/test/Transforms/Scalarizer/intrinsics.ll b/llvm/test/Transforms/Scalarizer/intrinsics.ll
index 73026c571302c..3e1c03c8a382b 100644
--- a/llvm/test/Transforms/Scalarizer/intrinsics.ll
+++ b/llvm/test/Transforms/Scalarizer/intrinsics.ll
@@ -28,6 +28,9 @@ declare <2 x i32> @llvm.umul.fix.sat.v2i32(<2 x i32>, <2 x i32>, i32)
 declare <2 x i32> @llvm.fptosi.sat.v2i32.v2f32(<2 x float>)
 declare <2 x i32> @llvm.fptoui.sat.v2i32.v2f32(<2 x float>)
 
+; Bool return type, overloaded on fp operand type
+declare <2 x i1> @llvm.is.fpclass(<2 x float>, i32)
+
 
 define <2 x float> @scalarize_sqrt_v2f32(<2 x float> %x) #0 {
 ; CHECK-LABEL: @scalarize_sqrt_v2f32(
@@ -206,3 +209,12 @@ define <2 x i32> @scalarize_fptoui_sat(<2 x float> %x) #0 {
   %sat = call <2 x i32> @llvm.fptoui.sat.v2i32.v2f32(<2 x float> %x)
   ret <2 x i32> %sat
 }
+
+define <2 x i1> @scalarize_is_fpclass(<2 x float> %x) #0 {
+; CHECK-LABEL: @scalarize_is_fpclass(
+; CHECK-NEXT:    [[ISFPCLASS:%.*]] = call <2 x i1> @llvm.is.fpclass.v2f32(<2 x float> [[X:%.*]], i32 123)
+; CHECK-NEXT:    ret <2 x i1> [[ISFPCLASS]]
+;
+  %isfpclass = call <2 x i1> @llvm.is.fpclass(<2 x float> %x, i32 123)
+  ret <2 x i1> %isfpclass
+}


        


More information about the llvm-commits mailing list