Skip to content

Commit 4a47f1c

Browse files
committed
[SelectionDAG][SVE] Support scalable vectors in getConstantFP()
Differential Revision: https://reviews.llvm.org/D85249
1 parent 09897b1 commit 4a47f1c

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1380,7 +1380,9 @@ SDValue SelectionDAG::getConstantFP(const ConstantFP &V, const SDLoc &DL,
13801380
}
13811381

13821382
SDValue Result(N, 0);
1383-
if (VT.isVector())
1383+
if (VT.isScalableVector())
1384+
Result = getSplatVector(VT, DL, Result);
1385+
else if (VT.isVector())
13841386
Result = getSplatBuildVector(VT, DL, Result);
13851387
NewSDValueDbgMsg(Result, "Creating fp constant: ", this);
13861388
return Result;

llvm/test/CodeGen/AArch64/sve-vector-splat.ll

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,5 +355,22 @@ define <vscale x 2 x double> @splat_nxv2f64_imm() {
355355
ret <vscale x 2 x double> %2
356356
}
357357

358+
define <vscale x 4 x i32> @splat_nxv4i32_fold(<vscale x 4 x i32> %x) {
359+
; CHECK-LABEL: splat_nxv4i32_fold:
360+
; CHECK: mov z0.s, #0
361+
; CHECK-NEXT: ret
362+
%r = sub <vscale x 4 x i32> %x, %x
363+
ret <vscale x 4 x i32> %r
364+
}
365+
366+
367+
define <vscale x 4 x float> @splat_nxv4f32_fold(<vscale x 4 x float> %x) {
368+
; CHECK-LABEL: splat_nxv4f32_fold:
369+
; CHECK: mov z0.s, #0
370+
; CHECK-NEXT: ret
371+
%r = fsub nnan <vscale x 4 x float> %x, %x
372+
ret <vscale x 4 x float> %r
373+
}
374+
358375
; +bf16 is required for the bfloat version.
359376
attributes #0 = { "target-features"="+sve,+bf16" }

0 commit comments

Comments
 (0)