Skip to content

Commit 5d5150f

Browse files
committed
[GlobalISel] Fix G_SEXT narrowScalar to bail out of unsupported type combination.
Similar to the issue with G_ZEXT that was fixed earlier, this is a quick to fall back if the source type is not exactly half of the dest type. Fixes the clang-cmake-aarch64-lld bot build. llvm-svn: 370847
1 parent 418a272 commit 5d5150f

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -619,13 +619,17 @@ LegalizerHelper::LegalizeResult LegalizerHelper::narrowScalar(MachineInstr &MI,
619619
if (TypeIdx != 0)
620620
return UnableToLegalize;
621621

622-
if (NarrowTy.getSizeInBits() != SizeOp0 / 2) {
622+
Register SrcReg = MI.getOperand(1).getReg();
623+
LLT SrcTy = MRI.getType(SrcReg);
624+
625+
// FIXME: support the general case where the requested NarrowTy may not be
626+
// the same as the source type. E.g. s128 = sext(s32)
627+
if ((SrcTy.getSizeInBits() != SizeOp0 / 2) ||
628+
SrcTy.getSizeInBits() != NarrowTy.getSizeInBits()) {
623629
LLVM_DEBUG(dbgs() << "Can't narrow sext to type " << NarrowTy << "\n");
624630
return UnableToLegalize;
625631
}
626632

627-
Register SrcReg = MI.getOperand(1).getReg();
628-
629633
// Shift the sign bit of the low register through the high register.
630634
auto ShiftAmt =
631635
MIRBuilder.buildConstant(LLT::scalar(64), NarrowTy.getSizeInBits() - 1);

0 commit comments

Comments
 (0)