mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-05 02:07:56 +00:00
701b911eac
Use the whole gammut of constant immediates available to set up a vector. Instead of using, for example, `mov w0, #0xffff; dup v0.4s, w0`, which transfers between register files, use the more efficient `movi v0.4s, #-1` instead. Not limited to just a few values, but any immediate value that can be encoded by all the variants of `FMOV`, `MOVI`, `MVNI`, thus eliminating the need to there be patterns to optimize special cases. Differential revision: https://reviews.llvm.org/D42133 llvm-svn: 326718
273 lines
8.3 KiB
LLVM
273 lines
8.3 KiB
LLVM
; RUN: llc < %s -mtriple=aarch64-- | FileCheck %s
|
|
|
|
; Check that building up a vector w/ only one non-zero lane initializes
|
|
; efficiently.
|
|
|
|
define <8 x i8> @v8i8z(i8 %t, i8 %s) nounwind {
|
|
%v = insertelement <8 x i8> <i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 undef>, i8 %s, i32 7
|
|
ret <8 x i8> %v
|
|
|
|
; CHECK-LABEL: v8i8z
|
|
; CHECK: movi d[[R:[0-9]+]], #0
|
|
; CHECK: mov v[[R]].b[7], w{{[0-9]+}}
|
|
}
|
|
|
|
define <16 x i8> @v16i8z(i8 %t, i8 %s) nounwind {
|
|
%v = insertelement <16 x i8> <i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 0, i8 undef>, i8 %s, i32 15
|
|
ret <16 x i8> %v
|
|
|
|
; CHECK-LABEL: v16i8z:
|
|
; CHECK: movi v[[R:[0-9]+]].2d, #0
|
|
; CHECK: mov v[[R]].b[15], w{{[0-9]+}}
|
|
}
|
|
|
|
define <4 x i16> @v4i16z(i16 %t, i16 %s) nounwind {
|
|
%v = insertelement <4 x i16> <i16 0, i16 0, i16 0, i16 undef>, i16 %s, i32 3
|
|
ret <4 x i16> %v
|
|
|
|
; CHECK-LABEL: v4i16z:
|
|
; CHECK: movi d[[R:[0-9]+]], #0
|
|
; CHECK: mov v[[R]].h[3], w{{[0-9]+}}
|
|
}
|
|
|
|
define <8 x i16> @v8i16z(i16 %t, i16 %s) nounwind {
|
|
%v = insertelement <8 x i16> <i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 0, i16 undef>, i16 %s, i32 7
|
|
ret <8 x i16> %v
|
|
|
|
; CHECK-LABEL: v8i16z:
|
|
; CHECK: movi v[[R:[0-9]+]].2d, #0
|
|
; CHECK: mov v[[R]].h[7], w{{[0-9]+}}
|
|
}
|
|
|
|
define <2 x i32> @v2i32z(i32 %t, i32 %s) nounwind {
|
|
%v = insertelement <2 x i32> <i32 0, i32 undef>, i32 %s, i32 1
|
|
ret <2 x i32> %v
|
|
|
|
; CHECK-LABEL: v2i32z:
|
|
; CHECK: movi d[[R:[0-9]+]], #0
|
|
; CHECK: mov v[[R]].s[1], w{{[0-9]+}}
|
|
}
|
|
|
|
define <4 x i32> @v4i32z(i32 %t, i32 %s) nounwind {
|
|
%v = insertelement <4 x i32> <i32 0, i32 0, i32 0, i32 undef>, i32 %s, i32 3
|
|
ret <4 x i32> %v
|
|
|
|
; CHECK-LABEL: v4i32z:
|
|
; CHECK: movi v[[R:[0-9]+]].2d, #0
|
|
; CHECK: mov v[[R]].s[3], w{{[0-9]+}}
|
|
}
|
|
|
|
define <2 x i64> @v2i64z(i64 %t, i64 %s) nounwind {
|
|
%v = insertelement <2 x i64> <i64 0, i64 undef>, i64 %s, i32 1
|
|
ret <2 x i64> %v
|
|
|
|
; CHECK-LABEL: v2i64z:
|
|
; CHECK: movi v[[R:[0-9]+]].2d, #0
|
|
; CHECK: mov v[[R]].d[1], x{{[0-9]+}}
|
|
}
|
|
|
|
define <2 x float> @v2f32z(float %t, float %s) nounwind {
|
|
%v = insertelement <2 x float> <float 0.0, float undef>, float %s, i32 1
|
|
ret <2 x float> %v
|
|
|
|
; CHECK-LABEL: v2f32z:
|
|
; CHECK: movi d[[R:[0-9]+]], #0
|
|
; CHECK: mov v[[R]].s[1], v{{[0-9]+}}.s[0]
|
|
}
|
|
|
|
define <4 x float> @v4f32z(float %t, float %s) nounwind {
|
|
%v = insertelement <4 x float> <float 0.0, float 0.0, float 0.0, float undef>, float %s, i32 3
|
|
ret <4 x float> %v
|
|
|
|
; CHECK-LABEL: v4f32z:
|
|
; CHECK: movi v[[R:[0-9]+]].2d, #0
|
|
; CHECK: mov v[[R]].s[3], v{{[0-9]+}}.s[0]
|
|
}
|
|
|
|
define <2 x double> @v2f64z(double %t, double %s) nounwind {
|
|
%v = insertelement <2 x double> <double 0.0, double undef>, double %s, i32 1
|
|
ret <2 x double> %v
|
|
|
|
; CHECK-LABEL: v2f64z:
|
|
; CHECK: movi v[[R:[0-9]+]].2d, #0
|
|
; CHECK: mov v[[R]].d[1], v{{[0-9]+}}.d[0]
|
|
}
|
|
|
|
; Check that building up a vector w/ only one non-ones lane initializes
|
|
; efficiently.
|
|
|
|
define <8 x i8> @v8i8m(i8 %t, i8 %s) nounwind {
|
|
%v = insertelement <8 x i8> <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 undef>, i8 %s, i32 7
|
|
ret <8 x i8> %v
|
|
|
|
; CHECK-LABEL: v8i8m
|
|
; CHECK: movi d{{[0-9]+}}, #0xffffffffffffffff
|
|
; CHECK: mov v[[R]].b[7], w{{[0-9]+}}
|
|
}
|
|
|
|
define <16 x i8> @v16i8m(i8 %t, i8 %s) nounwind {
|
|
%v = insertelement <16 x i8> <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 undef>, i8 %s, i32 15
|
|
ret <16 x i8> %v
|
|
|
|
; CHECK-LABEL: v16i8m
|
|
; CHECK: movi v[[R:[0-9]+]].2d, #0xffffffffffffffff
|
|
; CHECK: mov v[[R]].b[15], w{{[0-9]+}}
|
|
}
|
|
|
|
define <4 x i16> @v4i16m(i16 %t, i16 %s) nounwind {
|
|
%v = insertelement <4 x i16> <i16 -1, i16 -1, i16 -1, i16 undef>, i16 %s, i32 3
|
|
ret <4 x i16> %v
|
|
|
|
; CHECK-LABEL: v4i16m
|
|
; CHECK: movi d{{[0-9]+}}, #0xffffffffffffffff
|
|
; CHECK: mov v[[R]].h[3], w{{[0-9]+}}
|
|
}
|
|
|
|
define <8 x i16> @v8i16m(i16 %t, i16 %s) nounwind {
|
|
%v = insertelement <8 x i16> <i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 -1, i16 undef>, i16 %s, i32 7
|
|
ret <8 x i16> %v
|
|
|
|
; CHECK-LABEL: v8i16m
|
|
; CHECK: movi v[[R:[0-9]+]].2d, #0xffffffffffffffff
|
|
; CHECK: mov v[[R]].h[7], w{{[0-9]+}}
|
|
}
|
|
|
|
define <2 x i32> @v2i32m(i32 %t, i32 %s) nounwind {
|
|
%v = insertelement <2 x i32> <i32 -1, i32 undef>, i32 %s, i32 1
|
|
ret <2 x i32> %v
|
|
|
|
; CHECK-LABEL: v2i32m
|
|
; CHECK: movi d{{[0-9]+}}, #0xffffffffffffffff
|
|
; CHECK: mov v[[R]].s[1], w{{[0-9]+}}
|
|
}
|
|
|
|
define <4 x i32> @v4i32m(i32 %t, i32 %s) nounwind {
|
|
%v = insertelement <4 x i32> <i32 -1, i32 -1, i32 -1, i32 undef>, i32 %s, i32 3
|
|
ret <4 x i32> %v
|
|
|
|
; CHECK-LABEL: v4i32m
|
|
; CHECK: movi v[[R:[0-9]+]].2d, #0xffffffffffffffff
|
|
; CHECK: mov v[[R]].s[3], w{{[0-9]+}}
|
|
}
|
|
|
|
define <2 x i64> @v2i64m(i64 %t, i64 %s) nounwind {
|
|
%v = insertelement <2 x i64> <i64 -1, i64 undef>, i64 %s, i32 1
|
|
ret <2 x i64> %v
|
|
|
|
; CHECK-LABEL: v2i64m
|
|
; CHECK: movi v[[R:[0-9]+]].2d, #0xffffffffffffffff
|
|
; CHECK: mov v[[R]].d[1], x{{[0-9]+}}
|
|
}
|
|
|
|
; Check that building up a vector w/ some constants initializes efficiently.
|
|
|
|
define void @v8i8st(<8 x i8>* %p, i8 %s) nounwind {
|
|
%v = insertelement <8 x i8> <i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 undef>, i8 %s, i32 7
|
|
store <8 x i8> %v, <8 x i8>* %p, align 8
|
|
ret void
|
|
|
|
; CHECK-LABEL: v8i8st:
|
|
; CHECK: movi v[[R:[0-9]+]].8b, #1
|
|
; CHECK: mov v[[R]].b[7], w{{[0-9]+}}
|
|
; CHECK: str d[[R]], [x{{[0-9]+}}]
|
|
}
|
|
|
|
define void @v16i8st(<16 x i8>* %p, i8 %s) nounwind {
|
|
%v = insertelement <16 x i8> <i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 -128, i8 undef>, i8 %s, i32 15
|
|
store <16 x i8> %v, <16 x i8>* %p, align 16
|
|
ret void
|
|
|
|
; CHECK-LABEL: v16i8st:
|
|
; CHECK: movi v[[R:[0-9]+]].16b, #128
|
|
; CHECK: mov v[[R]].b[15], w{{[0-9]+}}
|
|
; CHECK: str q[[R]], [x{{[0-9]+}}]
|
|
}
|
|
|
|
define void @v4i16st(<4 x i16>* %p, i16 %s) nounwind {
|
|
%v = insertelement <4 x i16> <i16 21760, i16 21760, i16 21760, i16 undef>, i16 %s, i32 3
|
|
store <4 x i16> %v, <4 x i16>* %p, align 8
|
|
ret void
|
|
|
|
; CHECK-LABEL: v4i16st:
|
|
; CHECK: movi v[[R:[0-9]+]].4h, #85, lsl #8
|
|
; CHECK: mov v[[R]].h[3], w{{[0-9]+}}
|
|
; CHECK: str d[[R]], [x{{[0-9]+}}]
|
|
}
|
|
|
|
define void @v8i16st(<8 x i16>* %p, i16 %s) nounwind {
|
|
%v = insertelement <8 x i16> <i16 -21761, i16 -21761, i16 -21761, i16 -21761, i16 -21761, i16 -21761, i16 -21761, i16 undef>, i16 %s, i32 7
|
|
store <8 x i16> %v, <8 x i16>* %p, align 16
|
|
ret void
|
|
|
|
; CHECK-LABEL: v8i16st:
|
|
; CHECK: mvni v[[R:[0-9]+]].8h, #85, lsl #8
|
|
; CHECK: mov v[[R]].h[7], w{{[0-9]+}}
|
|
; CHECK: str q[[R]], [x{{[0-9]+}}]
|
|
}
|
|
|
|
define void @v2i32st(<2 x i32>* %p, i32 %s) nounwind {
|
|
%v = insertelement <2 x i32> <i32 983040, i32 undef>, i32 %s, i32 1
|
|
store <2 x i32> %v, <2 x i32>* %p, align 8
|
|
ret void
|
|
|
|
; CHECK-LABEL: v2i32st:
|
|
; CHECK: movi v[[R:[0-9]+]].2s, #15, lsl #16
|
|
; CHECK: mov v[[R]].s[1], w{{[0-9]+}}
|
|
; CHECK: str d[[R]], [x{{[0-9]+}}]
|
|
}
|
|
|
|
define void @v4i32st(<4 x i32>* %p, i32 %s) nounwind {
|
|
%v = insertelement <4 x i32> <i32 16318463, i32 16318463, i32 16318463, i32 undef>, i32 %s, i32 3
|
|
store <4 x i32> %v, <4 x i32>* %p, align 16
|
|
ret void
|
|
|
|
; CHECK-LABEL: v4i32st:
|
|
; CHECK: movi v[[R:[0-9]+]].4s, #248, msl #16
|
|
; CHECK: mov v[[R]].s[3], w{{[0-9]+}}
|
|
; CHECK: str q[[R]], [x{{[0-9]+}}]
|
|
}
|
|
|
|
define void @v2i64st(<2 x i64>* %p, i64 %s) nounwind {
|
|
%v = insertelement <2 x i64> <i64 13835058055282163712, i64 undef>, i64 %s, i32 1
|
|
store <2 x i64> %v, <2 x i64>* %p, align 16
|
|
ret void
|
|
|
|
; CHECK-LABEL: v2i64st:
|
|
; CHECK: fmov v[[R:[0-9]+]].2d, #-2.0
|
|
; CHECK: mov v[[R]].d[1], x{{[0-9]+}}
|
|
; CHECK: str q[[R]], [x{{[0-9]+}}]
|
|
}
|
|
|
|
define void @v2f32st(<2 x float>* %p, float %s) nounwind {
|
|
%v = insertelement <2 x float> <float 2.0, float undef>, float %s, i32 1
|
|
store <2 x float> %v, <2 x float>* %p, align 8
|
|
ret void
|
|
|
|
; CHECK-LABEL: v2f32st:
|
|
; CHECK: movi v[[R:[0-9]+]].2s, #64, lsl #24
|
|
; CHECK: mov v[[R]].s[1], v{{[0-9]+}}.s[0]
|
|
; CHECK: str d[[R]], [x{{[0-9]+}}]
|
|
}
|
|
|
|
define void @v4f32st(<4 x float>* %p, float %s) nounwind {
|
|
%v = insertelement <4 x float> <float -2.0, float -2.0, float -2.0, float undef>, float %s, i32 3
|
|
store <4 x float> %v, <4 x float>* %p, align 16
|
|
ret void
|
|
|
|
; CHECK-LABEL: v4f32st:
|
|
; CHECK: movi v[[R:[0-9]+]].4s, #192, lsl #24
|
|
; CHECK: mov v[[R]].s[3], v{{[0-9]+}}.s[0]
|
|
; CHECK: str q[[R]], [x{{[0-9]+}}]
|
|
}
|
|
|
|
define void @v2f64st(<2 x double>* %p, double %s) nounwind {
|
|
%v = insertelement <2 x double> <double 2.0, double undef>, double %s, i32 1
|
|
store <2 x double> %v, <2 x double>* %p, align 16
|
|
ret void
|
|
|
|
; CHECK-LABEL: v2f64st:
|
|
; CHECK: fmov v[[R:[0-9]+]].2d, #2.0
|
|
; CHECK: mov v[[R]].d[1], v{{[0-9]+}}.d[0]
|
|
; CHECK: str q[[R]], [x{{[0-9]+}}]
|
|
}
|