Fix bug while building FP16 constant vectors for AArch64

Summary: Building FP16 constant vectors caused the FP16 data to be bitcast to i64.  This patch creates a BITCAST node with the correct value, and adds a test to verify correct handling.

Reviewers: mcrosier

Reviewed By: mcrosier

Subscribers: mcrosier, jmolloy, ab, srhines, llvm-commits, rengolin, aemerson

Differential Revision: http://reviews.llvm.org/D8369

llvm-svn: 232562
This commit is contained in:
Pirama Arumuga Nainar 2015-03-17 23:10:29 +00:00
parent c085eca176
commit 12aeefc63b
2 changed files with 13 additions and 2 deletions

View File

@ -5892,8 +5892,10 @@ FailedModImm:
if (VT.getVectorElementType().isFloatingPoint()) { if (VT.getVectorElementType().isFloatingPoint()) {
SmallVector<SDValue, 8> Ops; SmallVector<SDValue, 8> Ops;
MVT NewType = EVT EltTy = VT.getVectorElementType();
(VT.getVectorElementType() == MVT::f32) ? MVT::i32 : MVT::i64; assert ((EltTy == MVT::f16 || EltTy == MVT::f32 || EltTy == MVT::f64) &&
"Unsupported floating-point vector type");
MVT NewType = MVT::getIntegerVT(EltTy.getSizeInBits());
for (unsigned i = 0; i < NumElts; ++i) for (unsigned i = 0; i < NumElts; ++i)
Ops.push_back(DAG.getNode(ISD::BITCAST, dl, NewType, Op.getOperand(i))); Ops.push_back(DAG.getNode(ISD::BITCAST, dl, NewType, Op.getOperand(i)));
EVT VecVT = EVT::getVectorVT(*DAG.getContext(), NewType, NumElts); EVT VecVT = EVT::getVectorVT(*DAG.getContext(), NewType, NumElts);

View File

@ -12,6 +12,15 @@ entry:
} }
define <4 x half> @build_h4(<4 x half> %a) {
entry:
; CHECK-LABEL: build_h4:
; CHECK: movz [[GPR:w[0-9]+]], #0x3ccd
; CHECK: dup v0.4h, [[GPR]]
ret <4 x half> <half 0xH3CCD, half 0xH3CCD, half 0xH3CCD, half 0xH3CCD>
}
define <4 x half> @sub_h(<4 x half> %a, <4 x half> %b) { define <4 x half> @sub_h(<4 x half> %a, <4 x half> %b) {
entry: entry:
; CHECK-LABEL: sub_h: ; CHECK-LABEL: sub_h: