blob: 6444ef9b0bd67d78dfcd0c3387e0079a673230b8 [file] [edit]
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -mtriple=aarch64 -verify-machineinstrs < %s | FileCheck %s
; all-constant vector -> should fold to a plain constant (24)
define i32 @test_const() {
; CHECK-LABEL: test_const:
; CHECK: // %bb.0:
; CHECK-NEXT: mov w0, #24 // =0x18
; CHECK-NEXT: ret
%r = call i32 @llvm.vector.reduce.mul.v4i32(<4 x i32> <i32 1, i32 2, i32 3, i32 4>)
ret i32 %r
}
; 8-element vector, product = 40320
define i32 @test_const_wide() {
; CHECK-LABEL: test_const_wide:
; CHECK: // %bb.0:
; CHECK-NEXT: mov w0, #40320 // =0x9d80
; CHECK-NEXT: ret
%r = call i32 @llvm.vector.reduce.mul.v8i32(<8 x i32> <i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8>)
ret i32 %r
}
; non-constant input -> should NOT fold
define i32 @test_nonconst(<4 x i32> %v) {
; CHECK-LABEL: test_nonconst:
; CHECK: // %bb.0:
; CHECK-NEXT: mov d1, v0.d[1]
; CHECK-NEXT: mul v0.2s, v0.2s, v1.2s
; CHECK-NEXT: mul v0.2s, v0.2s, v0.s[1]
; CHECK-NEXT: fmov w0, s0
; CHECK-NEXT: ret
%r = call i32 @llvm.vector.reduce.mul.v4i32(<4 x i32> %v)
ret i32 %r
}
; vector containing a poison element -> return poison
define i32 @test_poison() {
; CHECK-LABEL: test_poison:
; CHECK: // %bb.0:
; CHECK-NEXT: ret
%r = call i32 @llvm.vector.reduce.mul.v4i32(<4 x i32> <i32 1, i32 2, i32 poison, i32 4>)
ret i32 %r
}
; vector containing zero and poison -> return poison
define i32 @test_zero_and_poison() {
; CHECK-LABEL: test_zero_and_poison:
; CHECK: // %bb.0:
; CHECK-NEXT: ret
%r = call i32 @llvm.vector.reduce.mul.v4i32(<4 x i32> <i32 0, i32 2, i32 poison, i32 4>)
ret i32 %r
}
; vector containing an undef element -> leave constant fold to expansion
define i32 @test_undef() {
; CHECK-LABEL: test_undef:
; CHECK: // %bb.0:
; CHECK-NEXT: mov w0, wzr
; CHECK-NEXT: ret
%r = call i32 @llvm.vector.reduce.mul.v4i32(<4 x i32> <i32 1, i32 2, i32 undef, i32 4>)
ret i32 %r
}
; vector containing an undef element -> leave constant fold to expansion
define i32 @test_zero_and_undef() {
; CHECK-LABEL: test_zero_and_undef:
; CHECK: // %bb.0:
; CHECK-NEXT: mov w0, wzr
; CHECK-NEXT: ret
%r = call i32 @llvm.vector.reduce.mul.v4i32(<4 x i32> <i32 0, i32 2, i32 undef, i32 4>)
ret i32 %r
}