[SystemZ] Add CodeGen support for integer vector types
This the first of a series of patches to add CodeGen support exploiting
the instructions of the z13 vector facility. This patch adds support
for the native integer vector types (v16i8, v8i16, v4i32, v2i64).
When the vector facility is present, we default to the new vector ABI.
This is characterized by two major differences:
- Vector types are passed/returned in vector registers
(except for unnamed arguments of a variable-argument list function).
- Vector types are at most 8-byte aligned.
The reason for the choice of 8-byte vector alignment is that the hardware
is able to efficiently load vectors at 8-byte alignment, and the ABI only
guarantees 8-byte alignment of the stack pointer, so requiring any higher
alignment for vectors would require dynamic stack re-alignment code.
However, for compatibility with old code that may use vector types, when
*not* using the vector facility, the old alignment rules (vector types
are naturally aligned) remain in use.
These alignment rules are not only implemented at the C language level
(implemented in clang), but also at the LLVM IR level. This is done
by selecting a different DataLayout string depending on whether the
vector ABI is in effect or not.
Based on a patch by Richard Sandiford.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236521 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-05 19:25:42 +00:00
|
|
|
; Test vector extraction.
|
|
|
|
;
|
|
|
|
; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z13 | FileCheck %s
|
|
|
|
|
|
|
|
; Test v16i8 extraction of the first element.
|
|
|
|
define i8 @f1(<16 x i8> %val) {
|
|
|
|
; CHECK-LABEL: f1:
|
|
|
|
; CHECK: vlgvb %r2, %v24, 0
|
|
|
|
; CHECK: br %r14
|
|
|
|
%ret = extractelement <16 x i8> %val, i32 0
|
|
|
|
ret i8 %ret
|
|
|
|
}
|
|
|
|
|
|
|
|
; Test v16i8 extraction of the last element.
|
|
|
|
define i8 @f2(<16 x i8> %val) {
|
|
|
|
; CHECK-LABEL: f2:
|
|
|
|
; CHECK: vlgvb %r2, %v24, 15
|
|
|
|
; CHECK: br %r14
|
|
|
|
%ret = extractelement <16 x i8> %val, i32 15
|
|
|
|
ret i8 %ret
|
|
|
|
}
|
|
|
|
|
|
|
|
; Test v16i8 extractions of an absurd element number. This must compile
|
|
|
|
; but we don't care what it does.
|
|
|
|
define i8 @f3(<16 x i8> %val) {
|
|
|
|
; CHECK-LABEL: f3:
|
|
|
|
; CHECK-NOT: vlgvb %r2, %v24, 100000
|
|
|
|
; CHECK: br %r14
|
|
|
|
%ret = extractelement <16 x i8> %val, i32 100000
|
|
|
|
ret i8 %ret
|
|
|
|
}
|
|
|
|
|
|
|
|
; Test v16i8 extraction of a variable element.
|
|
|
|
define i8 @f4(<16 x i8> %val, i32 %index) {
|
|
|
|
; CHECK-LABEL: f4:
|
|
|
|
; CHECK: vlgvb %r2, %v24, 0(%r2)
|
|
|
|
; CHECK: br %r14
|
|
|
|
%ret = extractelement <16 x i8> %val, i32 %index
|
|
|
|
ret i8 %ret
|
|
|
|
}
|
|
|
|
|
|
|
|
; Test v8i16 extraction of the first element.
|
|
|
|
define i16 @f5(<8 x i16> %val) {
|
|
|
|
; CHECK-LABEL: f5:
|
|
|
|
; CHECK: vlgvh %r2, %v24, 0
|
|
|
|
; CHECK: br %r14
|
|
|
|
%ret = extractelement <8 x i16> %val, i32 0
|
|
|
|
ret i16 %ret
|
|
|
|
}
|
|
|
|
|
|
|
|
; Test v8i16 extraction of the last element.
|
|
|
|
define i16 @f6(<8 x i16> %val) {
|
|
|
|
; CHECK-LABEL: f6:
|
|
|
|
; CHECK: vlgvh %r2, %v24, 7
|
|
|
|
; CHECK: br %r14
|
|
|
|
%ret = extractelement <8 x i16> %val, i32 7
|
|
|
|
ret i16 %ret
|
|
|
|
}
|
|
|
|
|
|
|
|
; Test v8i16 extractions of an absurd element number. This must compile
|
|
|
|
; but we don't care what it does.
|
|
|
|
define i16 @f7(<8 x i16> %val) {
|
|
|
|
; CHECK-LABEL: f7:
|
|
|
|
; CHECK-NOT: vlgvh %r2, %v24, 100000
|
|
|
|
; CHECK: br %r14
|
|
|
|
%ret = extractelement <8 x i16> %val, i32 100000
|
|
|
|
ret i16 %ret
|
|
|
|
}
|
|
|
|
|
|
|
|
; Test v8i16 extraction of a variable element.
|
|
|
|
define i16 @f8(<8 x i16> %val, i32 %index) {
|
|
|
|
; CHECK-LABEL: f8:
|
|
|
|
; CHECK: vlgvh %r2, %v24, 0(%r2)
|
|
|
|
; CHECK: br %r14
|
|
|
|
%ret = extractelement <8 x i16> %val, i32 %index
|
|
|
|
ret i16 %ret
|
|
|
|
}
|
|
|
|
|
|
|
|
; Test v4i32 extraction of the first element.
|
|
|
|
define i32 @f9(<4 x i32> %val) {
|
|
|
|
; CHECK-LABEL: f9:
|
|
|
|
; CHECK: vlgvf %r2, %v24, 0
|
|
|
|
; CHECK: br %r14
|
|
|
|
%ret = extractelement <4 x i32> %val, i32 0
|
|
|
|
ret i32 %ret
|
|
|
|
}
|
|
|
|
|
|
|
|
; Test v4i32 extraction of the last element.
|
|
|
|
define i32 @f10(<4 x i32> %val) {
|
|
|
|
; CHECK-LABEL: f10:
|
|
|
|
; CHECK: vlgvf %r2, %v24, 3
|
|
|
|
; CHECK: br %r14
|
|
|
|
%ret = extractelement <4 x i32> %val, i32 3
|
|
|
|
ret i32 %ret
|
|
|
|
}
|
|
|
|
|
|
|
|
; Test v4i32 extractions of an absurd element number. This must compile
|
|
|
|
; but we don't care what it does.
|
|
|
|
define i32 @f11(<4 x i32> %val) {
|
|
|
|
; CHECK-LABEL: f11:
|
|
|
|
; CHECK-NOT: vlgvf %r2, %v24, 100000
|
|
|
|
; CHECK: br %r14
|
|
|
|
%ret = extractelement <4 x i32> %val, i32 100000
|
|
|
|
ret i32 %ret
|
|
|
|
}
|
|
|
|
|
|
|
|
; Test v4i32 extraction of a variable element.
|
|
|
|
define i32 @f12(<4 x i32> %val, i32 %index) {
|
|
|
|
; CHECK-LABEL: f12:
|
|
|
|
; CHECK: vlgvf %r2, %v24, 0(%r2)
|
|
|
|
; CHECK: br %r14
|
|
|
|
%ret = extractelement <4 x i32> %val, i32 %index
|
|
|
|
ret i32 %ret
|
|
|
|
}
|
|
|
|
|
|
|
|
; Test v2i64 extraction of the first element.
|
|
|
|
define i64 @f13(<2 x i64> %val) {
|
|
|
|
; CHECK-LABEL: f13:
|
|
|
|
; CHECK: vlgvg %r2, %v24, 0
|
|
|
|
; CHECK: br %r14
|
|
|
|
%ret = extractelement <2 x i64> %val, i32 0
|
|
|
|
ret i64 %ret
|
|
|
|
}
|
|
|
|
|
|
|
|
; Test v2i64 extraction of the last element.
|
|
|
|
define i64 @f14(<2 x i64> %val) {
|
|
|
|
; CHECK-LABEL: f14:
|
|
|
|
; CHECK: vlgvg %r2, %v24, 1
|
|
|
|
; CHECK: br %r14
|
|
|
|
%ret = extractelement <2 x i64> %val, i32 1
|
|
|
|
ret i64 %ret
|
|
|
|
}
|
|
|
|
|
|
|
|
; Test v2i64 extractions of an absurd element number. This must compile
|
|
|
|
; but we don't care what it does.
|
|
|
|
define i64 @f15(<2 x i64> %val) {
|
|
|
|
; CHECK-LABEL: f15:
|
|
|
|
; CHECK-NOT: vlgvg %r2, %v24, 100000
|
|
|
|
; CHECK: br %r14
|
|
|
|
%ret = extractelement <2 x i64> %val, i32 100000
|
|
|
|
ret i64 %ret
|
|
|
|
}
|
|
|
|
|
|
|
|
; Test v2i64 extraction of a variable element.
|
|
|
|
define i64 @f16(<2 x i64> %val, i32 %index) {
|
|
|
|
; CHECK-LABEL: f16:
|
|
|
|
; CHECK: vlgvg %r2, %v24, 0(%r2)
|
|
|
|
; CHECK: br %r14
|
|
|
|
%ret = extractelement <2 x i64> %val, i32 %index
|
|
|
|
ret i64 %ret
|
|
|
|
}
|
|
|
|
|
2015-05-05 19:27:45 +00:00
|
|
|
; Test v4f32 extraction of element 0.
|
|
|
|
define float @f17(<4 x float> %val) {
|
|
|
|
; CHECK-LABEL: f17:
|
|
|
|
; CHECK: vlr %v0, %v24
|
|
|
|
; CHECK: br %r14
|
|
|
|
%ret = extractelement <4 x float> %val, i32 0
|
|
|
|
ret float %ret
|
|
|
|
}
|
|
|
|
|
|
|
|
; Test v4f32 extraction of element 1.
|
|
|
|
define float @f18(<4 x float> %val) {
|
|
|
|
; CHECK-LABEL: f18:
|
|
|
|
; CHECK: vrepf %v0, %v24, 1
|
|
|
|
; CHECK: br %r14
|
|
|
|
%ret = extractelement <4 x float> %val, i32 1
|
|
|
|
ret float %ret
|
|
|
|
}
|
|
|
|
|
|
|
|
; Test v4f32 extraction of element 2.
|
|
|
|
define float @f19(<4 x float> %val) {
|
|
|
|
; CHECK-LABEL: f19:
|
|
|
|
; CHECK: vrepf %v0, %v24, 2
|
|
|
|
; CHECK: br %r14
|
|
|
|
%ret = extractelement <4 x float> %val, i32 2
|
|
|
|
ret float %ret
|
|
|
|
}
|
|
|
|
|
|
|
|
; Test v4f32 extraction of element 3.
|
|
|
|
define float @f20(<4 x float> %val) {
|
|
|
|
; CHECK-LABEL: f20:
|
|
|
|
; CHECK: vrepf %v0, %v24, 3
|
|
|
|
; CHECK: br %r14
|
|
|
|
%ret = extractelement <4 x float> %val, i32 3
|
|
|
|
ret float %ret
|
|
|
|
}
|
|
|
|
|
|
|
|
; Test v4f32 extractions of an absurd element number. This must compile
|
|
|
|
; but we don't care what it does.
|
|
|
|
define float @f21(<4 x float> %val) {
|
|
|
|
%ret = extractelement <4 x float> %val, i32 100000
|
|
|
|
ret float %ret
|
|
|
|
}
|
|
|
|
|
|
|
|
; Test v4f32 extraction of a variable element.
|
|
|
|
define float @f22(<4 x float> %val, i32 %index) {
|
|
|
|
; CHECK-LABEL: f22:
|
|
|
|
; CHECK: vlgvf [[REG:%r[0-5]]], %v24, 0(%r2)
|
|
|
|
; CHECK: vlvgf %v0, [[REG]], 0
|
|
|
|
; CHECK: br %r14
|
|
|
|
%ret = extractelement <4 x float> %val, i32 %index
|
|
|
|
ret float %ret
|
|
|
|
}
|
|
|
|
|
2015-05-05 19:26:48 +00:00
|
|
|
; Test v2f64 extraction of the first element.
|
|
|
|
define double @f23(<2 x double> %val) {
|
|
|
|
; CHECK-LABEL: f23:
|
|
|
|
; CHECK: vlr %v0, %v24
|
|
|
|
; CHECK: br %r14
|
|
|
|
%ret = extractelement <2 x double> %val, i32 0
|
|
|
|
ret double %ret
|
|
|
|
}
|
|
|
|
|
|
|
|
; Test v2f64 extraction of the last element.
|
|
|
|
define double @f24(<2 x double> %val) {
|
|
|
|
; CHECK-LABEL: f24:
|
|
|
|
; CHECK: vrepg %v0, %v24, 1
|
|
|
|
; CHECK: br %r14
|
|
|
|
%ret = extractelement <2 x double> %val, i32 1
|
|
|
|
ret double %ret
|
|
|
|
}
|
|
|
|
|
|
|
|
; Test v2f64 extractions of an absurd element number. This must compile
|
|
|
|
; but we don't care what it does.
|
|
|
|
define double @f25(<2 x double> %val) {
|
|
|
|
%ret = extractelement <2 x double> %val, i32 100000
|
|
|
|
ret double %ret
|
|
|
|
}
|
|
|
|
|
|
|
|
; Test v2f64 extraction of a variable element.
|
|
|
|
define double @f26(<2 x double> %val, i32 %index) {
|
|
|
|
; CHECK-LABEL: f26:
|
|
|
|
; CHECK: vlgvg [[REG:%r[0-5]]], %v24, 0(%r2)
|
|
|
|
; CHECK: ldgr %f0, [[REG]]
|
|
|
|
; CHECK: br %r14
|
|
|
|
%ret = extractelement <2 x double> %val, i32 %index
|
|
|
|
ret double %ret
|
|
|
|
}
|
|
|
|
|
[SystemZ] Add CodeGen support for integer vector types
This the first of a series of patches to add CodeGen support exploiting
the instructions of the z13 vector facility. This patch adds support
for the native integer vector types (v16i8, v8i16, v4i32, v2i64).
When the vector facility is present, we default to the new vector ABI.
This is characterized by two major differences:
- Vector types are passed/returned in vector registers
(except for unnamed arguments of a variable-argument list function).
- Vector types are at most 8-byte aligned.
The reason for the choice of 8-byte vector alignment is that the hardware
is able to efficiently load vectors at 8-byte alignment, and the ABI only
guarantees 8-byte alignment of the stack pointer, so requiring any higher
alignment for vectors would require dynamic stack re-alignment code.
However, for compatibility with old code that may use vector types, when
*not* using the vector facility, the old alignment rules (vector types
are naturally aligned) remain in use.
These alignment rules are not only implemented at the C language level
(implemented in clang), but also at the LLVM IR level. This is done
by selecting a different DataLayout string depending on whether the
vector ABI is in effect or not.
Based on a patch by Richard Sandiford.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236521 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-05 19:25:42 +00:00
|
|
|
; Test v16i8 extraction of a variable element with an offset.
|
|
|
|
define i8 @f27(<16 x i8> %val, i32 %index) {
|
|
|
|
; CHECK-LABEL: f27:
|
|
|
|
; CHECK: vlgvb %r2, %v24, 1(%r2)
|
|
|
|
; CHECK: br %r14
|
|
|
|
%add = add i32 %index, 1
|
|
|
|
%ret = extractelement <16 x i8> %val, i32 %add
|
|
|
|
ret i8 %ret
|
|
|
|
}
|