2017-05-10 17:42:49 +08:00
|
|
|
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
|
|
|
; RUN: opt < %s -expand-reductions -S | FileCheck %s
|
|
|
|
; Tests without a target which should expand all reductions
|
2020-10-03 09:30:53 +08:00
|
|
|
declare i64 @llvm.vector.reduce.add.v2i64(<2 x i64>)
|
|
|
|
declare i64 @llvm.vector.reduce.mul.v2i64(<2 x i64>)
|
|
|
|
declare i64 @llvm.vector.reduce.and.v2i64(<2 x i64>)
|
|
|
|
declare i64 @llvm.vector.reduce.or.v2i64(<2 x i64>)
|
|
|
|
declare i64 @llvm.vector.reduce.xor.v2i64(<2 x i64>)
|
2017-05-10 17:42:49 +08:00
|
|
|
|
2020-10-03 09:30:53 +08:00
|
|
|
declare float @llvm.vector.reduce.fadd.f32.v4f32(float, <4 x float>)
|
|
|
|
declare float @llvm.vector.reduce.fmul.f32.v4f32(float, <4 x float>)
|
2017-05-10 17:42:49 +08:00
|
|
|
|
2020-10-03 09:30:53 +08:00
|
|
|
declare i64 @llvm.vector.reduce.smax.v2i64(<2 x i64>)
|
|
|
|
declare i64 @llvm.vector.reduce.smin.v2i64(<2 x i64>)
|
|
|
|
declare i64 @llvm.vector.reduce.umax.v2i64(<2 x i64>)
|
|
|
|
declare i64 @llvm.vector.reduce.umin.v2i64(<2 x i64>)
|
2017-05-10 17:42:49 +08:00
|
|
|
|
2020-10-03 09:30:53 +08:00
|
|
|
declare double @llvm.vector.reduce.fmax.v2f64(<2 x double>)
|
|
|
|
declare double @llvm.vector.reduce.fmin.v2f64(<2 x double>)
|
2017-05-10 17:42:49 +08:00
|
|
|
|
2020-10-03 09:30:53 +08:00
|
|
|
declare i8 @llvm.vector.reduce.and.i8.v3i8(<3 x i8>)
|
2017-05-10 17:42:49 +08:00
|
|
|
|
|
|
|
define i64 @add_i64(<2 x i64> %vec) {
|
|
|
|
; CHECK-LABEL: @add_i64(
|
|
|
|
; CHECK-NEXT: entry:
|
2020-12-30 06:28:17 +08:00
|
|
|
; CHECK-NEXT: [[RDX_SHUF:%.*]] = shufflevector <2 x i64> [[VEC:%.*]], <2 x i64> poison, <2 x i32> <i32 1, i32 undef>
|
2017-05-10 17:42:49 +08:00
|
|
|
; CHECK-NEXT: [[BIN_RDX:%.*]] = add <2 x i64> [[VEC]], [[RDX_SHUF]]
|
|
|
|
; CHECK-NEXT: [[TMP0:%.*]] = extractelement <2 x i64> [[BIN_RDX]], i32 0
|
|
|
|
; CHECK-NEXT: ret i64 [[TMP0]]
|
|
|
|
;
|
|
|
|
entry:
|
2020-10-03 09:30:53 +08:00
|
|
|
%r = call i64 @llvm.vector.reduce.add.v2i64(<2 x i64> %vec)
|
2017-05-10 17:42:49 +08:00
|
|
|
ret i64 %r
|
|
|
|
}
|
|
|
|
|
|
|
|
define i64 @mul_i64(<2 x i64> %vec) {
|
|
|
|
; CHECK-LABEL: @mul_i64(
|
|
|
|
; CHECK-NEXT: entry:
|
2020-12-30 06:28:17 +08:00
|
|
|
; CHECK-NEXT: [[RDX_SHUF:%.*]] = shufflevector <2 x i64> [[VEC:%.*]], <2 x i64> poison, <2 x i32> <i32 1, i32 undef>
|
2017-05-10 17:42:49 +08:00
|
|
|
; CHECK-NEXT: [[BIN_RDX:%.*]] = mul <2 x i64> [[VEC]], [[RDX_SHUF]]
|
|
|
|
; CHECK-NEXT: [[TMP0:%.*]] = extractelement <2 x i64> [[BIN_RDX]], i32 0
|
|
|
|
; CHECK-NEXT: ret i64 [[TMP0]]
|
|
|
|
;
|
|
|
|
entry:
|
2020-10-03 09:30:53 +08:00
|
|
|
%r = call i64 @llvm.vector.reduce.mul.v2i64(<2 x i64> %vec)
|
2017-05-10 17:42:49 +08:00
|
|
|
ret i64 %r
|
|
|
|
}
|
|
|
|
|
|
|
|
define i64 @and_i64(<2 x i64> %vec) {
|
|
|
|
; CHECK-LABEL: @and_i64(
|
|
|
|
; CHECK-NEXT: entry:
|
2020-12-30 06:28:17 +08:00
|
|
|
; CHECK-NEXT: [[RDX_SHUF:%.*]] = shufflevector <2 x i64> [[VEC:%.*]], <2 x i64> poison, <2 x i32> <i32 1, i32 undef>
|
2017-05-10 17:42:49 +08:00
|
|
|
; CHECK-NEXT: [[BIN_RDX:%.*]] = and <2 x i64> [[VEC]], [[RDX_SHUF]]
|
|
|
|
; CHECK-NEXT: [[TMP0:%.*]] = extractelement <2 x i64> [[BIN_RDX]], i32 0
|
|
|
|
; CHECK-NEXT: ret i64 [[TMP0]]
|
|
|
|
;
|
|
|
|
entry:
|
2020-10-03 09:30:53 +08:00
|
|
|
%r = call i64 @llvm.vector.reduce.and.v2i64(<2 x i64> %vec)
|
2017-05-10 17:42:49 +08:00
|
|
|
ret i64 %r
|
|
|
|
}
|
|
|
|
|
|
|
|
define i64 @or_i64(<2 x i64> %vec) {
|
|
|
|
; CHECK-LABEL: @or_i64(
|
|
|
|
; CHECK-NEXT: entry:
|
2020-12-30 06:28:17 +08:00
|
|
|
; CHECK-NEXT: [[RDX_SHUF:%.*]] = shufflevector <2 x i64> [[VEC:%.*]], <2 x i64> poison, <2 x i32> <i32 1, i32 undef>
|
2017-05-10 17:42:49 +08:00
|
|
|
; CHECK-NEXT: [[BIN_RDX:%.*]] = or <2 x i64> [[VEC]], [[RDX_SHUF]]
|
|
|
|
; CHECK-NEXT: [[TMP0:%.*]] = extractelement <2 x i64> [[BIN_RDX]], i32 0
|
|
|
|
; CHECK-NEXT: ret i64 [[TMP0]]
|
|
|
|
;
|
|
|
|
entry:
|
2020-10-03 09:30:53 +08:00
|
|
|
%r = call i64 @llvm.vector.reduce.or.v2i64(<2 x i64> %vec)
|
2017-05-10 17:42:49 +08:00
|
|
|
ret i64 %r
|
|
|
|
}
|
|
|
|
|
|
|
|
define i64 @xor_i64(<2 x i64> %vec) {
|
|
|
|
; CHECK-LABEL: @xor_i64(
|
|
|
|
; CHECK-NEXT: entry:
|
2020-12-30 06:28:17 +08:00
|
|
|
; CHECK-NEXT: [[RDX_SHUF:%.*]] = shufflevector <2 x i64> [[VEC:%.*]], <2 x i64> poison, <2 x i32> <i32 1, i32 undef>
|
2017-05-10 17:42:49 +08:00
|
|
|
; CHECK-NEXT: [[BIN_RDX:%.*]] = xor <2 x i64> [[VEC]], [[RDX_SHUF]]
|
|
|
|
; CHECK-NEXT: [[TMP0:%.*]] = extractelement <2 x i64> [[BIN_RDX]], i32 0
|
|
|
|
; CHECK-NEXT: ret i64 [[TMP0]]
|
|
|
|
;
|
|
|
|
entry:
|
2020-10-03 09:30:53 +08:00
|
|
|
%r = call i64 @llvm.vector.reduce.xor.v2i64(<2 x i64> %vec)
|
2017-05-10 17:42:49 +08:00
|
|
|
ret i64 %r
|
|
|
|
}
|
|
|
|
|
|
|
|
define float @fadd_f32(<4 x float> %vec) {
|
|
|
|
; CHECK-LABEL: @fadd_f32(
|
|
|
|
; CHECK-NEXT: entry:
|
2020-12-30 06:28:17 +08:00
|
|
|
; CHECK-NEXT: [[RDX_SHUF:%.*]] = shufflevector <4 x float> [[VEC:%.*]], <4 x float> poison, <4 x i32> <i32 2, i32 3, i32 undef, i32 undef>
|
2017-05-10 17:42:49 +08:00
|
|
|
; CHECK-NEXT: [[BIN_RDX:%.*]] = fadd fast <4 x float> [[VEC]], [[RDX_SHUF]]
|
2020-12-30 06:28:17 +08:00
|
|
|
; CHECK-NEXT: [[RDX_SHUF1:%.*]] = shufflevector <4 x float> [[BIN_RDX]], <4 x float> poison, <4 x i32> <i32 1, i32 undef, i32 undef, i32 undef>
|
2017-05-10 17:42:49 +08:00
|
|
|
; CHECK-NEXT: [[BIN_RDX2:%.*]] = fadd fast <4 x float> [[BIN_RDX]], [[RDX_SHUF1]]
|
|
|
|
; CHECK-NEXT: [[TMP0:%.*]] = extractelement <4 x float> [[BIN_RDX2]], i32 0
|
2020-09-12 21:08:07 +08:00
|
|
|
; CHECK-NEXT: [[BIN_RDX3:%.*]] = fadd fast float 0.000000e+00, [[TMP0]]
|
|
|
|
; CHECK-NEXT: ret float [[BIN_RDX3]]
|
2017-05-10 17:42:49 +08:00
|
|
|
;
|
|
|
|
entry:
|
2020-10-03 09:30:53 +08:00
|
|
|
%r = call fast float @llvm.vector.reduce.fadd.f32.v4f32(float 0.0, <4 x float> %vec)
|
2017-05-10 17:42:49 +08:00
|
|
|
ret float %r
|
|
|
|
}
|
|
|
|
|
2018-04-07 01:18:44 +08:00
|
|
|
define float @fadd_f32_accum(float %accum, <4 x float> %vec) {
|
|
|
|
; CHECK-LABEL: @fadd_f32_accum(
|
|
|
|
; CHECK-NEXT: entry:
|
2020-12-30 06:28:17 +08:00
|
|
|
; CHECK-NEXT: [[RDX_SHUF:%.*]] = shufflevector <4 x float> [[VEC:%.*]], <4 x float> poison, <4 x i32> <i32 2, i32 3, i32 undef, i32 undef>
|
2018-04-07 01:18:44 +08:00
|
|
|
; CHECK-NEXT: [[BIN_RDX:%.*]] = fadd fast <4 x float> [[VEC]], [[RDX_SHUF]]
|
2020-12-30 06:28:17 +08:00
|
|
|
; CHECK-NEXT: [[RDX_SHUF1:%.*]] = shufflevector <4 x float> [[BIN_RDX]], <4 x float> poison, <4 x i32> <i32 1, i32 undef, i32 undef, i32 undef>
|
2018-04-07 01:18:44 +08:00
|
|
|
; CHECK-NEXT: [[BIN_RDX2:%.*]] = fadd fast <4 x float> [[BIN_RDX]], [[RDX_SHUF1]]
|
|
|
|
; CHECK-NEXT: [[TMP0:%.*]] = extractelement <4 x float> [[BIN_RDX2]], i32 0
|
2020-09-12 21:08:07 +08:00
|
|
|
; CHECK-NEXT: [[BIN_RDX3:%.*]] = fadd fast float [[ACCUM:%.*]], [[TMP0]]
|
|
|
|
; CHECK-NEXT: ret float [[BIN_RDX3]]
|
2018-04-07 01:18:44 +08:00
|
|
|
;
|
|
|
|
entry:
|
2020-10-03 09:30:53 +08:00
|
|
|
%r = call fast float @llvm.vector.reduce.fadd.f32.v4f32(float %accum, <4 x float> %vec)
|
2018-04-07 01:18:44 +08:00
|
|
|
ret float %r
|
|
|
|
}
|
|
|
|
|
2017-05-10 17:42:49 +08:00
|
|
|
define float @fadd_f32_strict(<4 x float> %vec) {
|
|
|
|
; CHECK-LABEL: @fadd_f32_strict(
|
|
|
|
; CHECK-NEXT: entry:
|
2018-04-09 23:44:20 +08:00
|
|
|
; CHECK-NEXT: [[TMP0:%.*]] = extractelement <4 x float> [[VEC:%.*]], i32 0
|
|
|
|
; CHECK-NEXT: [[BIN_RDX:%.*]] = fadd float undef, [[TMP0]]
|
|
|
|
; CHECK-NEXT: [[TMP1:%.*]] = extractelement <4 x float> [[VEC]], i32 1
|
|
|
|
; CHECK-NEXT: [[BIN_RDX1:%.*]] = fadd float [[BIN_RDX]], [[TMP1]]
|
|
|
|
; CHECK-NEXT: [[TMP2:%.*]] = extractelement <4 x float> [[VEC]], i32 2
|
|
|
|
; CHECK-NEXT: [[BIN_RDX2:%.*]] = fadd float [[BIN_RDX1]], [[TMP2]]
|
|
|
|
; CHECK-NEXT: [[TMP3:%.*]] = extractelement <4 x float> [[VEC]], i32 3
|
|
|
|
; CHECK-NEXT: [[BIN_RDX3:%.*]] = fadd float [[BIN_RDX2]], [[TMP3]]
|
|
|
|
; CHECK-NEXT: ret float [[BIN_RDX3]]
|
2017-05-10 17:42:49 +08:00
|
|
|
;
|
|
|
|
entry:
|
2020-10-03 09:30:53 +08:00
|
|
|
%r = call float @llvm.vector.reduce.fadd.f32.v4f32(float undef, <4 x float> %vec)
|
2017-05-10 17:42:49 +08:00
|
|
|
ret float %r
|
|
|
|
}
|
|
|
|
|
2018-04-07 01:15:56 +08:00
|
|
|
define float @fadd_f32_strict_accum(float %accum, <4 x float> %vec) {
|
|
|
|
; CHECK-LABEL: @fadd_f32_strict_accum(
|
|
|
|
; CHECK-NEXT: entry:
|
2018-04-09 23:44:20 +08:00
|
|
|
; CHECK-NEXT: [[TMP0:%.*]] = extractelement <4 x float> [[VEC:%.*]], i32 0
|
|
|
|
; CHECK-NEXT: [[BIN_RDX:%.*]] = fadd float [[ACCUM:%.*]], [[TMP0]]
|
|
|
|
; CHECK-NEXT: [[TMP1:%.*]] = extractelement <4 x float> [[VEC]], i32 1
|
|
|
|
; CHECK-NEXT: [[BIN_RDX1:%.*]] = fadd float [[BIN_RDX]], [[TMP1]]
|
|
|
|
; CHECK-NEXT: [[TMP2:%.*]] = extractelement <4 x float> [[VEC]], i32 2
|
|
|
|
; CHECK-NEXT: [[BIN_RDX2:%.*]] = fadd float [[BIN_RDX1]], [[TMP2]]
|
|
|
|
; CHECK-NEXT: [[TMP3:%.*]] = extractelement <4 x float> [[VEC]], i32 3
|
|
|
|
; CHECK-NEXT: [[BIN_RDX3:%.*]] = fadd float [[BIN_RDX2]], [[TMP3]]
|
|
|
|
; CHECK-NEXT: ret float [[BIN_RDX3]]
|
2018-04-07 01:15:56 +08:00
|
|
|
;
|
|
|
|
entry:
|
2020-10-03 09:30:53 +08:00
|
|
|
%r = call float @llvm.vector.reduce.fadd.f32.v4f32(float %accum, <4 x float> %vec)
|
2018-04-07 01:15:56 +08:00
|
|
|
ret float %r
|
|
|
|
}
|
|
|
|
|
2017-05-10 17:42:49 +08:00
|
|
|
define float @fmul_f32(<4 x float> %vec) {
|
|
|
|
; CHECK-LABEL: @fmul_f32(
|
|
|
|
; CHECK-NEXT: entry:
|
2020-12-30 06:28:17 +08:00
|
|
|
; CHECK-NEXT: [[RDX_SHUF:%.*]] = shufflevector <4 x float> [[VEC:%.*]], <4 x float> poison, <4 x i32> <i32 2, i32 3, i32 undef, i32 undef>
|
2017-05-10 17:42:49 +08:00
|
|
|
; CHECK-NEXT: [[BIN_RDX:%.*]] = fmul fast <4 x float> [[VEC]], [[RDX_SHUF]]
|
2020-12-30 06:28:17 +08:00
|
|
|
; CHECK-NEXT: [[RDX_SHUF1:%.*]] = shufflevector <4 x float> [[BIN_RDX]], <4 x float> poison, <4 x i32> <i32 1, i32 undef, i32 undef, i32 undef>
|
2017-05-10 17:42:49 +08:00
|
|
|
; CHECK-NEXT: [[BIN_RDX2:%.*]] = fmul fast <4 x float> [[BIN_RDX]], [[RDX_SHUF1]]
|
|
|
|
; CHECK-NEXT: [[TMP0:%.*]] = extractelement <4 x float> [[BIN_RDX2]], i32 0
|
2020-09-12 21:08:07 +08:00
|
|
|
; CHECK-NEXT: [[BIN_RDX3:%.*]] = fmul fast float 1.000000e+00, [[TMP0]]
|
|
|
|
; CHECK-NEXT: ret float [[BIN_RDX3]]
|
2017-05-10 17:42:49 +08:00
|
|
|
;
|
|
|
|
entry:
|
2020-10-03 09:30:53 +08:00
|
|
|
%r = call fast float @llvm.vector.reduce.fmul.f32.v4f32(float 1.0, <4 x float> %vec)
|
2017-05-10 17:42:49 +08:00
|
|
|
ret float %r
|
|
|
|
}
|
|
|
|
|
2018-04-07 01:18:44 +08:00
|
|
|
define float @fmul_f32_accum(float %accum, <4 x float> %vec) {
|
|
|
|
; CHECK-LABEL: @fmul_f32_accum(
|
|
|
|
; CHECK-NEXT: entry:
|
2020-12-30 06:28:17 +08:00
|
|
|
; CHECK-NEXT: [[RDX_SHUF:%.*]] = shufflevector <4 x float> [[VEC:%.*]], <4 x float> poison, <4 x i32> <i32 2, i32 3, i32 undef, i32 undef>
|
2018-04-07 01:18:44 +08:00
|
|
|
; CHECK-NEXT: [[BIN_RDX:%.*]] = fmul fast <4 x float> [[VEC]], [[RDX_SHUF]]
|
2020-12-30 06:28:17 +08:00
|
|
|
; CHECK-NEXT: [[RDX_SHUF1:%.*]] = shufflevector <4 x float> [[BIN_RDX]], <4 x float> poison, <4 x i32> <i32 1, i32 undef, i32 undef, i32 undef>
|
2018-04-07 01:18:44 +08:00
|
|
|
; CHECK-NEXT: [[BIN_RDX2:%.*]] = fmul fast <4 x float> [[BIN_RDX]], [[RDX_SHUF1]]
|
|
|
|
; CHECK-NEXT: [[TMP0:%.*]] = extractelement <4 x float> [[BIN_RDX2]], i32 0
|
2020-09-12 21:08:07 +08:00
|
|
|
; CHECK-NEXT: [[BIN_RDX3:%.*]] = fmul fast float [[ACCUM:%.*]], [[TMP0]]
|
|
|
|
; CHECK-NEXT: ret float [[BIN_RDX3]]
|
2018-04-07 01:18:44 +08:00
|
|
|
;
|
|
|
|
entry:
|
2020-10-03 09:30:53 +08:00
|
|
|
%r = call fast float @llvm.vector.reduce.fmul.f32.v4f32(float %accum, <4 x float> %vec)
|
2018-04-07 01:18:44 +08:00
|
|
|
ret float %r
|
|
|
|
}
|
|
|
|
|
2018-04-07 01:15:56 +08:00
|
|
|
define float @fmul_f32_strict(<4 x float> %vec) {
|
|
|
|
; CHECK-LABEL: @fmul_f32_strict(
|
|
|
|
; CHECK-NEXT: entry:
|
2018-04-09 23:44:20 +08:00
|
|
|
; CHECK-NEXT: [[TMP0:%.*]] = extractelement <4 x float> [[VEC:%.*]], i32 0
|
|
|
|
; CHECK-NEXT: [[BIN_RDX:%.*]] = fmul float undef, [[TMP0]]
|
|
|
|
; CHECK-NEXT: [[TMP1:%.*]] = extractelement <4 x float> [[VEC]], i32 1
|
|
|
|
; CHECK-NEXT: [[BIN_RDX1:%.*]] = fmul float [[BIN_RDX]], [[TMP1]]
|
|
|
|
; CHECK-NEXT: [[TMP2:%.*]] = extractelement <4 x float> [[VEC]], i32 2
|
|
|
|
; CHECK-NEXT: [[BIN_RDX2:%.*]] = fmul float [[BIN_RDX1]], [[TMP2]]
|
|
|
|
; CHECK-NEXT: [[TMP3:%.*]] = extractelement <4 x float> [[VEC]], i32 3
|
|
|
|
; CHECK-NEXT: [[BIN_RDX3:%.*]] = fmul float [[BIN_RDX2]], [[TMP3]]
|
|
|
|
; CHECK-NEXT: ret float [[BIN_RDX3]]
|
2018-04-07 01:15:56 +08:00
|
|
|
;
|
|
|
|
entry:
|
2020-10-03 09:30:53 +08:00
|
|
|
%r = call float @llvm.vector.reduce.fmul.f32.v4f32(float undef, <4 x float> %vec)
|
2018-04-07 01:15:56 +08:00
|
|
|
ret float %r
|
|
|
|
}
|
|
|
|
|
|
|
|
define float @fmul_f32_strict_accum(float %accum, <4 x float> %vec) {
|
|
|
|
; CHECK-LABEL: @fmul_f32_strict_accum(
|
|
|
|
; CHECK-NEXT: entry:
|
2018-04-09 23:44:20 +08:00
|
|
|
; CHECK-NEXT: [[TMP0:%.*]] = extractelement <4 x float> [[VEC:%.*]], i32 0
|
|
|
|
; CHECK-NEXT: [[BIN_RDX:%.*]] = fmul float [[ACCUM:%.*]], [[TMP0]]
|
|
|
|
; CHECK-NEXT: [[TMP1:%.*]] = extractelement <4 x float> [[VEC]], i32 1
|
|
|
|
; CHECK-NEXT: [[BIN_RDX1:%.*]] = fmul float [[BIN_RDX]], [[TMP1]]
|
|
|
|
; CHECK-NEXT: [[TMP2:%.*]] = extractelement <4 x float> [[VEC]], i32 2
|
|
|
|
; CHECK-NEXT: [[BIN_RDX2:%.*]] = fmul float [[BIN_RDX1]], [[TMP2]]
|
|
|
|
; CHECK-NEXT: [[TMP3:%.*]] = extractelement <4 x float> [[VEC]], i32 3
|
|
|
|
; CHECK-NEXT: [[BIN_RDX3:%.*]] = fmul float [[BIN_RDX2]], [[TMP3]]
|
|
|
|
; CHECK-NEXT: ret float [[BIN_RDX3]]
|
2018-04-07 01:15:56 +08:00
|
|
|
;
|
|
|
|
entry:
|
2020-10-03 09:30:53 +08:00
|
|
|
%r = call float @llvm.vector.reduce.fmul.f32.v4f32(float %accum, <4 x float> %vec)
|
2018-04-07 01:15:56 +08:00
|
|
|
ret float %r
|
|
|
|
}
|
|
|
|
|
2017-05-10 17:42:49 +08:00
|
|
|
define i64 @smax_i64(<2 x i64> %vec) {
|
|
|
|
; CHECK-LABEL: @smax_i64(
|
|
|
|
; CHECK-NEXT: entry:
|
2020-12-30 06:28:17 +08:00
|
|
|
; CHECK-NEXT: [[RDX_SHUF:%.*]] = shufflevector <2 x i64> [[VEC:%.*]], <2 x i64> poison, <2 x i32> <i32 1, i32 undef>
|
2017-05-10 17:42:49 +08:00
|
|
|
; CHECK-NEXT: [[RDX_MINMAX_CMP:%.*]] = icmp sgt <2 x i64> [[VEC]], [[RDX_SHUF]]
|
|
|
|
; CHECK-NEXT: [[RDX_MINMAX_SELECT:%.*]] = select <2 x i1> [[RDX_MINMAX_CMP]], <2 x i64> [[VEC]], <2 x i64> [[RDX_SHUF]]
|
|
|
|
; CHECK-NEXT: [[TMP0:%.*]] = extractelement <2 x i64> [[RDX_MINMAX_SELECT]], i32 0
|
|
|
|
; CHECK-NEXT: ret i64 [[TMP0]]
|
|
|
|
;
|
|
|
|
entry:
|
2020-10-03 09:30:53 +08:00
|
|
|
%r = call i64 @llvm.vector.reduce.smax.v2i64(<2 x i64> %vec)
|
2017-05-10 17:42:49 +08:00
|
|
|
ret i64 %r
|
|
|
|
}
|
|
|
|
|
|
|
|
define i64 @smin_i64(<2 x i64> %vec) {
|
|
|
|
; CHECK-LABEL: @smin_i64(
|
|
|
|
; CHECK-NEXT: entry:
|
2020-12-30 06:28:17 +08:00
|
|
|
; CHECK-NEXT: [[RDX_SHUF:%.*]] = shufflevector <2 x i64> [[VEC:%.*]], <2 x i64> poison, <2 x i32> <i32 1, i32 undef>
|
2017-05-10 17:42:49 +08:00
|
|
|
; CHECK-NEXT: [[RDX_MINMAX_CMP:%.*]] = icmp slt <2 x i64> [[VEC]], [[RDX_SHUF]]
|
|
|
|
; CHECK-NEXT: [[RDX_MINMAX_SELECT:%.*]] = select <2 x i1> [[RDX_MINMAX_CMP]], <2 x i64> [[VEC]], <2 x i64> [[RDX_SHUF]]
|
|
|
|
; CHECK-NEXT: [[TMP0:%.*]] = extractelement <2 x i64> [[RDX_MINMAX_SELECT]], i32 0
|
|
|
|
; CHECK-NEXT: ret i64 [[TMP0]]
|
|
|
|
;
|
|
|
|
entry:
|
2020-10-03 09:30:53 +08:00
|
|
|
%r = call i64 @llvm.vector.reduce.smin.v2i64(<2 x i64> %vec)
|
2017-05-10 17:42:49 +08:00
|
|
|
ret i64 %r
|
|
|
|
}
|
|
|
|
|
|
|
|
define i64 @umax_i64(<2 x i64> %vec) {
|
|
|
|
; CHECK-LABEL: @umax_i64(
|
|
|
|
; CHECK-NEXT: entry:
|
2020-12-30 06:28:17 +08:00
|
|
|
; CHECK-NEXT: [[RDX_SHUF:%.*]] = shufflevector <2 x i64> [[VEC:%.*]], <2 x i64> poison, <2 x i32> <i32 1, i32 undef>
|
2017-05-10 17:42:49 +08:00
|
|
|
; CHECK-NEXT: [[RDX_MINMAX_CMP:%.*]] = icmp ugt <2 x i64> [[VEC]], [[RDX_SHUF]]
|
|
|
|
; CHECK-NEXT: [[RDX_MINMAX_SELECT:%.*]] = select <2 x i1> [[RDX_MINMAX_CMP]], <2 x i64> [[VEC]], <2 x i64> [[RDX_SHUF]]
|
|
|
|
; CHECK-NEXT: [[TMP0:%.*]] = extractelement <2 x i64> [[RDX_MINMAX_SELECT]], i32 0
|
|
|
|
; CHECK-NEXT: ret i64 [[TMP0]]
|
|
|
|
;
|
|
|
|
entry:
|
2020-10-03 09:30:53 +08:00
|
|
|
%r = call i64 @llvm.vector.reduce.umax.v2i64(<2 x i64> %vec)
|
2017-05-10 17:42:49 +08:00
|
|
|
ret i64 %r
|
|
|
|
}
|
|
|
|
|
|
|
|
define i64 @umin_i64(<2 x i64> %vec) {
|
|
|
|
; CHECK-LABEL: @umin_i64(
|
|
|
|
; CHECK-NEXT: entry:
|
2020-12-30 06:28:17 +08:00
|
|
|
; CHECK-NEXT: [[RDX_SHUF:%.*]] = shufflevector <2 x i64> [[VEC:%.*]], <2 x i64> poison, <2 x i32> <i32 1, i32 undef>
|
2017-05-10 17:42:49 +08:00
|
|
|
; CHECK-NEXT: [[RDX_MINMAX_CMP:%.*]] = icmp ult <2 x i64> [[VEC]], [[RDX_SHUF]]
|
|
|
|
; CHECK-NEXT: [[RDX_MINMAX_SELECT:%.*]] = select <2 x i1> [[RDX_MINMAX_CMP]], <2 x i64> [[VEC]], <2 x i64> [[RDX_SHUF]]
|
|
|
|
; CHECK-NEXT: [[TMP0:%.*]] = extractelement <2 x i64> [[RDX_MINMAX_SELECT]], i32 0
|
|
|
|
; CHECK-NEXT: ret i64 [[TMP0]]
|
|
|
|
;
|
|
|
|
entry:
|
2020-10-03 09:30:53 +08:00
|
|
|
%r = call i64 @llvm.vector.reduce.umin.v2i64(<2 x i64> %vec)
|
2017-05-10 17:42:49 +08:00
|
|
|
ret i64 %r
|
|
|
|
}
|
|
|
|
|
2020-09-12 21:08:07 +08:00
|
|
|
; FIXME: Expand using maxnum intrinsic?
|
|
|
|
|
2017-05-10 17:42:49 +08:00
|
|
|
define double @fmax_f64(<2 x double> %vec) {
|
|
|
|
; CHECK-LABEL: @fmax_f64(
|
|
|
|
; CHECK-NEXT: entry:
|
2020-10-03 09:30:53 +08:00
|
|
|
; CHECK-NEXT: [[R:%.*]] = call double @llvm.vector.reduce.fmax.v2f64(<2 x double> [[VEC:%.*]])
|
2020-09-12 21:08:07 +08:00
|
|
|
; CHECK-NEXT: ret double [[R]]
|
2017-05-10 17:42:49 +08:00
|
|
|
;
|
|
|
|
entry:
|
2020-10-03 09:30:53 +08:00
|
|
|
%r = call double @llvm.vector.reduce.fmax.v2f64(<2 x double> %vec)
|
2017-05-10 17:42:49 +08:00
|
|
|
ret double %r
|
|
|
|
}
|
|
|
|
|
2020-09-12 21:08:07 +08:00
|
|
|
; FIXME: Expand using minnum intrinsic?
|
|
|
|
|
2017-05-10 17:42:49 +08:00
|
|
|
define double @fmin_f64(<2 x double> %vec) {
|
|
|
|
; CHECK-LABEL: @fmin_f64(
|
|
|
|
; CHECK-NEXT: entry:
|
2020-10-03 09:30:53 +08:00
|
|
|
; CHECK-NEXT: [[R:%.*]] = call double @llvm.vector.reduce.fmin.v2f64(<2 x double> [[VEC:%.*]])
|
2020-09-12 21:08:07 +08:00
|
|
|
; CHECK-NEXT: ret double [[R]]
|
2017-05-10 17:42:49 +08:00
|
|
|
;
|
|
|
|
entry:
|
2020-10-03 09:30:53 +08:00
|
|
|
%r = call double @llvm.vector.reduce.fmin.v2f64(<2 x double> %vec)
|
2017-05-10 17:42:49 +08:00
|
|
|
ret double %r
|
|
|
|
}
|
2019-11-03 11:59:12 +08:00
|
|
|
|
2020-09-12 21:08:07 +08:00
|
|
|
; FIXME: Why is this not expanded?
|
|
|
|
|
2019-11-03 11:59:12 +08:00
|
|
|
; Test when the vector size is not power of two.
|
|
|
|
define i8 @test_v3i8(<3 x i8> %a) nounwind {
|
|
|
|
; CHECK-LABEL: @test_v3i8(
|
|
|
|
; CHECK-NEXT: entry:
|
2020-10-03 09:30:53 +08:00
|
|
|
; CHECK-NEXT: [[B:%.*]] = call i8 @llvm.vector.reduce.and.v3i8(<3 x i8> [[A:%.*]])
|
2020-09-12 21:08:07 +08:00
|
|
|
; CHECK-NEXT: ret i8 [[B]]
|
2019-11-03 11:59:12 +08:00
|
|
|
;
|
|
|
|
entry:
|
2020-10-03 09:30:53 +08:00
|
|
|
%b = call i8 @llvm.vector.reduce.and.i8.v3i8(<3 x i8> %a)
|
2019-11-03 11:59:12 +08:00
|
|
|
ret i8 %b
|
|
|
|
}
|