diff --git a/llvm/test/Transforms/LoopVectorize/is_fpclass.ll b/llvm/test/Transforms/LoopVectorize/is_fpclass.ll new file mode 100644 --- /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: bb: +; CHECK-NEXT: br label [[BB2:%.*]] +; CHECK: bb1: +; CHECK-NEXT: ret void +; CHECK: bb2: +; CHECK-NEXT: [[I:%.*]] = phi i64 [ 0, [[BB:%.*]] ], [ [[I7:%.*]], [[BB2]] ] +; 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 [[BB1:%.*]], label [[BB2]] +; +bb: + br label %bb2 + +bb1: + ret void + +bb2: + %i = phi i64 [ 0, %bb ], [ %i7, %bb2 ] + %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 %bb1, label %bb2 +} + +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 --- /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 --- a/llvm/test/Transforms/Scalarizer/intrinsics.ll +++ b/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 +}