[llvm] e0f3302 - [ValueTracking] Support scalable vector splats in computeKnownFPClass (#170325)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 2 09:56:43 PST 2025
Author: Yingwei Zheng
Date: 2025-12-02T17:56:38Z
New Revision: e0f330293edb929152f44f1566d986b74ad5c1fc
URL: https://github.com/llvm/llvm-project/commit/e0f330293edb929152f44f1566d986b74ad5c1fc
DIFF: https://github.com/llvm/llvm-project/commit/e0f330293edb929152f44f1566d986b74ad5c1fc.diff
LOG: [ValueTracking] Support scalable vector splats in computeKnownFPClass (#170325)
Address comment
https://github.com/llvm/llvm-project/pull/169904#discussion_r2576299467
Added:
Modified:
llvm/lib/Analysis/ValueTracking.cpp
llvm/test/Transforms/Attributor/nofpclass.ll
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index dbceb8e557849..eb8650fd0eb60 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -5877,6 +5877,12 @@ void computeKnownFPClass(const Value *V, const APInt &DemandedElts,
break;
}
case Instruction::ShuffleVector: {
+ // Handle vector splat idiom
+ if (Value *Splat = getSplatValue(V)) {
+ computeKnownFPClass(Splat, Known, InterestedClasses, Q, Depth + 1);
+ break;
+ }
+
// For undef elements, we don't know anything about the common state of
// the shuffle result.
APInt DemandedLHS, DemandedRHS;
diff --git a/llvm/test/Transforms/Attributor/nofpclass.ll b/llvm/test/Transforms/Attributor/nofpclass.ll
index a9ebdaa397015..d82dc412f5e36 100644
--- a/llvm/test/Transforms/Attributor/nofpclass.ll
+++ b/llvm/test/Transforms/Attributor/nofpclass.ll
@@ -2667,15 +2667,10 @@ define [4 x float] @constant_aggregate_zero() {
}
define <vscale x 4 x float> @scalable_splat_pnorm() {
-; CHECK-CV: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
-; CHECK-CV-LABEL: define noundef <vscale x 4 x float> @scalable_splat_pnorm
-; CHECK-CV-SAME: () #[[ATTR3]] {
-; CHECK-CV-NEXT: ret <vscale x 4 x float> splat (float 1.000000e+00)
-;
-; CHECK-CI: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
-; CHECK-CI-LABEL: define noundef nofpclass(nan inf zero sub nnorm) <vscale x 4 x float> @scalable_splat_pnorm
-; CHECK-CI-SAME: () #[[ATTR3]] {
-; CHECK-CI-NEXT: ret <vscale x 4 x float> splat (float 1.000000e+00)
+; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
+; CHECK-LABEL: define noundef nofpclass(nan inf zero sub nnorm) <vscale x 4 x float> @scalable_splat_pnorm
+; CHECK-SAME: () #[[ATTR3]] {
+; CHECK-NEXT: ret <vscale x 4 x float> splat (float 1.000000e+00)
;
ret <vscale x 4 x float> splat (float 1.0)
}
@@ -2689,6 +2684,19 @@ define <vscale x 4 x float> @scalable_splat_zero() {
ret <vscale x 4 x float> zeroinitializer
}
+define <vscale x 4 x float> @scalable_splat_nnan(float nofpclass(nan) %x) {
+; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
+; CHECK-LABEL: define nofpclass(nan) <vscale x 4 x float> @scalable_splat_nnan
+; CHECK-SAME: (float nofpclass(nan) [[X:%.*]]) #[[ATTR3]] {
+; CHECK-NEXT: [[HEAD:%.*]] = insertelement <vscale x 4 x float> poison, float [[X]], i32 0
+; CHECK-NEXT: [[SPLAT:%.*]] = shufflevector <vscale x 4 x float> [[HEAD]], <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer
+; CHECK-NEXT: ret <vscale x 4 x float> [[SPLAT]]
+;
+ %head = insertelement <vscale x 4 x float> poison, float %x, i32 0
+ %splat = shufflevector <vscale x 4 x float> %head, <vscale x 4 x float> poison, <vscale x 4 x i32> zeroinitializer
+ ret <vscale x 4 x float> %splat
+}
+
; Verify we do not derive 'nofpclass(inf zero sub norm)' for the argument __x.
; See https://github.com/llvm/llvm-project/issues/78507
@@ -2989,5 +2997,7 @@ attributes #5 = { "denormal-fp-math"="ieee,positive-zero" }
;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
; CGSCC-CI: {{.*}}
; CGSCC-CV: {{.*}}
+; CHECK-CI: {{.*}}
+; CHECK-CV: {{.*}}
; TUNIT-CI: {{.*}}
; TUNIT-CV: {{.*}}
More information about the llvm-commits
mailing list