[PATCH] D149050: [Vectorize] Pre-commit tests for D148905

Jay Foad via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 24 03:25:49 PDT 2023


foad updated this revision to Diff 516344.
foad added a comment.

Better readability.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D149050/new/

https://reviews.llvm.org/D149050

Files:
  llvm/test/Transforms/LoopVectorize/is_fpclass.ll
  llvm/test/Transforms/SLPVectorizer/is_fpclass.ll
  llvm/test/Transforms/Scalarizer/intrinsics.ll


Index: llvm/test/Transforms/Scalarizer/intrinsics.ll
===================================================================
--- llvm/test/Transforms/Scalarizer/intrinsics.ll
+++ llvm/test/Transforms/Scalarizer/intrinsics.ll
@@ -28,6 +28,9 @@
 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 @@
   %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
+}
Index: llvm/test/Transforms/SLPVectorizer/is_fpclass.ll
===================================================================
--- /dev/null
+++ 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)
Index: llvm/test/Transforms/LoopVectorize/is_fpclass.ll
===================================================================
--- /dev/null
+++ 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)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149050.516344.patch
Type: text/x-patch
Size: 4310 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230424/0455a037/attachment.bin>


More information about the llvm-commits mailing list