From 0a376e89169345201c6d44fd7378484baeabfed9 Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Fri, 11 Apr 2025 10:11:38 +0100 Subject: [PATCH] [X86] getConstVector - remove raw bits -> fp handling and leave it to getNode/FoldConstantArithmetic getConstVector could only handle f32/f64 vector element types from raw APInt bit data - instead of trying to add all supported fp types, just bitcast the integer equivalent and leave it getNode/FoldConstantArithmetic to perform the constant bitcast conversion Tentative fix for a regression reported after #133913 --- llvm/lib/Target/X86/X86ISelLowering.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index 42ef817e014567..6e6431008e6805 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -4014,6 +4014,7 @@ static SDValue getConstVector(ArrayRef Bits, const APInt &Undefs, } MVT EltVT = ConstVecVT.getVectorElementType(); + MVT EltIntVT = EltVT.changeTypeToInteger(); for (unsigned i = 0, e = Bits.size(); i != e; ++i) { if (Undefs[i]) { Ops.append(Split ? 2 : 1, DAG.getUNDEF(EltVT)); @@ -4024,14 +4025,8 @@ static SDValue getConstVector(ArrayRef Bits, const APInt &Undefs, if (Split) { Ops.push_back(DAG.getConstant(V.extractBits(32, 0), dl, EltVT)); Ops.push_back(DAG.getConstant(V.extractBits(32, 32), dl, EltVT)); - } else if (EltVT == MVT::f32) { - APFloat FV(APFloat::IEEEsingle(), V); - Ops.push_back(DAG.getConstantFP(FV, dl, EltVT)); - } else if (EltVT == MVT::f64) { - APFloat FV(APFloat::IEEEdouble(), V); - Ops.push_back(DAG.getConstantFP(FV, dl, EltVT)); } else { - Ops.push_back(DAG.getConstant(V, dl, EltVT)); + Ops.push_back(DAG.getBitcast(EltVT, DAG.getConstant(V, dl, EltIntVT))); } }