[llvm] r206496 - Improve ARM64 vector creation
Louis Gerbarg
lgg at apple.com
Thu Apr 17 13:51:50 PDT 2014
Author: louis
Date: Thu Apr 17 15:51:50 2014
New Revision: 206496
URL: http://llvm.org/viewvc/llvm-project?rev=206496&view=rev
Log:
Improve ARM64 vector creation
This patch improves the performance of vector creation in caseiswhere where
several of the lanes in the vector are a constant floating point value. It
also includes new patterns to fold together some of the instructions when the
value is 0.0f. Test cases included.
rdar://16349427
Added:
llvm/trunk/test/CodeGen/ARM64/vector-insertion.ll
Modified:
llvm/trunk/lib/Target/ARM64/ARM64ISelLowering.cpp
llvm/trunk/lib/Target/ARM64/ARM64InstrInfo.td
Modified: llvm/trunk/lib/Target/ARM64/ARM64ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM64/ARM64ISelLowering.cpp?rev=206496&r1=206495&r2=206496&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM64/ARM64ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/ARM64/ARM64ISelLowering.cpp Thu Apr 17 15:51:50 2014
@@ -4891,7 +4891,7 @@ FailedModImm:
if (!isa<ConstantFPSDNode>(V) && !isa<ConstantSDNode>(V))
isConstant = false;
- if (isa<ConstantSDNode>(V)) {
+ if (isa<ConstantSDNode>(V) || isa<ConstantFPSDNode>(V)) {
++NumConstantLanes;
if (!ConstantValue.getNode())
ConstantValue = V;
@@ -4955,7 +4955,7 @@ FailedModImm:
for (unsigned i = 0; i < NumElts; ++i) {
SDValue V = Op.getOperand(i);
SDValue LaneIdx = DAG.getConstant(i, MVT::i64);
- if (!isa<ConstantSDNode>(V)) {
+ if (!isa<ConstantSDNode>(V) && !isa<ConstantFPSDNode>(V)) {
// Note that type legalization likely mucked about with the VT of the
// source operand, so we may have to convert it here before inserting.
Val = DAG.getNode(ISD::INSERT_VECTOR_ELT, dl, VT, Val, V, LaneIdx);
Modified: llvm/trunk/lib/Target/ARM64/ARM64InstrInfo.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM64/ARM64InstrInfo.td?rev=206496&r1=206495&r2=206496&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM64/ARM64InstrInfo.td (original)
+++ llvm/trunk/lib/Target/ARM64/ARM64InstrInfo.td Thu Apr 17 15:51:50 2014
@@ -3472,6 +3472,9 @@ def : Pat<(v4i32 immAllOnesV), (MOVIv2d_
def : Pat<(v8i16 immAllOnesV), (MOVIv2d_ns (i32 255))>;
def : Pat<(v16i8 immAllOnesV), (MOVIv2d_ns (i32 255))>;
+def : Pat<(v2f64 (ARM64dup (f64 fpimm0))), (MOVIv2d_ns (i32 0))>;
+def : Pat<(v4f32 (ARM64dup (f32 fpimm0))), (MOVIv2d_ns (i32 0))>;
+
// EDIT per word & halfword: 2s, 4h, 4s, & 8h
defm MOVI : SIMDModifiedImmVectorShift<0, 0b10, 0b00, "movi">;
def : Pat<(v2i32 (ARM64movi_shift imm0_255:$imm8, (i32 imm:$shift))),
Added: llvm/trunk/test/CodeGen/ARM64/vector-insertion.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM64/vector-insertion.ll?rev=206496&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/ARM64/vector-insertion.ll (added)
+++ llvm/trunk/test/CodeGen/ARM64/vector-insertion.ll Thu Apr 17 15:51:50 2014
@@ -0,0 +1,33 @@
+; RUN: llc -march=arm64 -mcpu=generic < %s | FileCheck %s
+
+define void @test0f(float* nocapture %x, float %a) #0 {
+entry:
+ %0 = insertelement <4 x float> <float undef, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00>, float %a, i32 0
+ %1 = bitcast float* %x to <4 x float>*
+ store <4 x float> %0, <4 x float>* %1, align 16
+ ret void
+
+ ; CHECK-LABEL: test0f
+ ; CHECK: movi.2d v[[TEMP:[0-9]+]], #0000000000000000
+ ; CHECK: ins.s v[[TEMP]][0], v{{[0-9]+}}[0]
+ ; CHECK: str q[[TEMP]], [x0]
+ ; CHECK: ret
+
+
+}
+
+
+define void @test1f(float* nocapture %x, float %a) #0 {
+entry:
+ %0 = insertelement <4 x float> <float undef, float 1.000000e+00, float 1.000000e+00, float 1.000000e+00>, float %a, i32 0
+ %1 = bitcast float* %x to <4 x float>*
+ store <4 x float> %0, <4 x float>* %1, align 16
+ ret void
+
+ ; CHECK-LABEL: test1f
+ ; CHECK: fmov s[[TEMP:[0-9]+]], #1.000000e+00
+ ; CHECK: dup.4s v[[TEMP2:[0-9]+]], v[[TEMP]][0]
+ ; CHECK: ins.s v[[TEMP2]][0], v0[0]
+ ; CHECK: str q[[TEMP2]], [x0]
+ ; CHECK: ret
+}
More information about the llvm-commits
mailing list