Index: llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp =================================================================== --- llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp +++ llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp @@ -7268,9 +7268,16 @@ // Vector selects can have a scalar predicate. If so, splat into a vector and // finish for later legalization attempts to try again. if (MaskTy.isScalar()) { + // FIXME: We shouldn't be promoting the mask type here, or even the + // broadcast. The broadcast should probably be handled as MoreElements, not + // lower. Register MaskElt = MaskReg; - if (MaskTy.getSizeInBits() < DstTy.getScalarSizeInBits()) - MaskElt = MIRBuilder.buildSExt(DstTy.getElementType(), MaskElt).getReg(0); + if (MaskTy.getSizeInBits() < DstTy.getScalarSizeInBits()) { + // FIXME: We have no way of knowing if this is FP without the original + // boolean's context. + MaskElt = MIRBuilder.buildBoolExt(DstTy.getElementType(), + MaskElt, false).getReg(0); + } // Generate a vector splat idiom to be pattern matched later. auto ShufSplat = MIRBuilder.buildShuffleSplat(DstTy, MaskElt); Observer.changingInstr(MI);