Skip to content

Commit 11f1314

Browse files
committed
init
1 parent 7fa104e commit 11f1314

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5106,6 +5106,29 @@ SDValue AArch64TargetLowering::LowerVectorINT_TO_FP(SDValue Op,
51065106
uint64_t VTSize = VT.getFixedSizeInBits();
51075107
uint64_t InVTSize = InVT.getFixedSizeInBits();
51085108
if (VTSize < InVTSize) {
5109+
// AArch64 doesn't have a direct vector instruction to convert
5110+
// fixed point to floating point AND narrow it at the same time.
5111+
// Additional rounding when the target is f32/f64 causes double
5112+
// rounding issues. Conversion to f16 is fine due to narrow width.
5113+
bool IsTargetf32 = VT.getVectorElementType() == MVT::f32;
5114+
bool IsTargetf16 = false;
5115+
if (Op.hasOneUse() &&
5116+
Op->user_begin()->getOpcode() == ISD::CONCAT_VECTORS) {
5117+
// Some vector types are split during legalization into half, followed by
5118+
// concatenation, followed by rounding to the original vector type. If we
5119+
// end up resolving to f16 type, we shouldn't worry about rounding errors.
5120+
SDNode *U = *Op->user_begin();
5121+
if (U->hasOneUse() && U->user_begin()->getOpcode() == ISD::FP_ROUND) {
5122+
EVT TmpVT = U->user_begin()->getValueType(0);
5123+
if (TmpVT.getScalarType() == MVT::f16)
5124+
IsTargetf16 = true;
5125+
}
5126+
}
5127+
5128+
if (IsTargetf32 && !IsTargetf16) {
5129+
return !IsStrict ? DAG.UnrollVectorOp(Op.getNode()) : SDValue();
5130+
}
5131+
51095132
MVT CastVT =
51105133
MVT::getVectorVT(MVT::getFloatingPointVT(InVT.getScalarSizeInBits()),
51115134
InVT.getVectorNumElements());

0 commit comments

Comments
 (0)