[llvm] 4a47f1c - [SelectionDAG][SVE] Support scalable vectors in getConstantFP()

Eli Friedman via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 4 15:36:03 PDT 2020


Author: Eli Friedman
Date: 2020-08-04T15:32:43-07:00
New Revision: 4a47f1c4cedb497915bba14f5288708cedb62767

URL: https://github.com/llvm/llvm-project/commit/4a47f1c4cedb497915bba14f5288708cedb62767
DIFF: https://github.com/llvm/llvm-project/commit/4a47f1c4cedb497915bba14f5288708cedb62767.diff

LOG: [SelectionDAG][SVE] Support scalable vectors in getConstantFP()

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

Added: 
    

Modified: 
    llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
    llvm/test/CodeGen/AArch64/sve-vector-splat.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index 7fdf8a82bae8..cd54834cf6ac 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -1380,7 +1380,9 @@ SDValue SelectionDAG::getConstantFP(const ConstantFP &V, const SDLoc &DL,
   }
 
   SDValue Result(N, 0);
-  if (VT.isVector())
+  if (VT.isScalableVector())
+    Result = getSplatVector(VT, DL, Result);
+  else if (VT.isVector())
     Result = getSplatBuildVector(VT, DL, Result);
   NewSDValueDbgMsg(Result, "Creating fp constant: ", this);
   return Result;

diff  --git a/llvm/test/CodeGen/AArch64/sve-vector-splat.ll b/llvm/test/CodeGen/AArch64/sve-vector-splat.ll
index 043e4ea135f3..7a765002ac9f 100644
--- a/llvm/test/CodeGen/AArch64/sve-vector-splat.ll
+++ b/llvm/test/CodeGen/AArch64/sve-vector-splat.ll
@@ -355,5 +355,22 @@ define <vscale x 2 x double> @splat_nxv2f64_imm() {
   ret <vscale x 2 x double> %2
 }
 
+define <vscale x 4 x i32> @splat_nxv4i32_fold(<vscale x 4 x i32> %x) {
+; CHECK-LABEL: splat_nxv4i32_fold:
+; CHECK: mov z0.s, #0
+; CHECK-NEXT: ret
+  %r = sub <vscale x 4 x i32> %x, %x
+  ret <vscale x 4 x i32> %r
+}
+
+
+define <vscale x 4 x float> @splat_nxv4f32_fold(<vscale x 4 x float> %x) {
+; CHECK-LABEL: splat_nxv4f32_fold:
+; CHECK: mov z0.s, #0
+; CHECK-NEXT: ret
+  %r = fsub nnan <vscale x 4 x float> %x, %x
+  ret <vscale x 4 x float> %r
+}
+
 ; +bf16 is required for the bfloat version.
 attributes #0 = { "target-features"="+sve,+bf16" }


        


More information about the llvm-commits mailing list