[llvm] 7edddee - [ExpandLargeFpConvert] Scalarize vector types. (#86954)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 2 23:46:03 PDT 2024
Author: Bevin Hansson
Date: 2024-04-03T08:45:59+02:00
New Revision: 7edddee2aa6a6183e40784c9141afec3e2eabb95
URL: https://github.com/llvm/llvm-project/commit/7edddee2aa6a6183e40784c9141afec3e2eabb95
DIFF: https://github.com/llvm/llvm-project/commit/7edddee2aa6a6183e40784c9141afec3e2eabb95.diff
LOG: [ExpandLargeFpConvert] Scalarize vector types. (#86954)
expand-large-fp-convert cannot handle vector types.
If overly large vector element types survive into
isel, they will likely be scalarized there, but since
isel cannot handle scalar integer types of that size,
it will assert.
Handle vector types in expand-large-fp-convert by
scalarizing them and then expanding the scalar type
operation. For large vectors, this results in a
*massive* code expansion, but it's better than
asserting.
Added:
Modified:
llvm/lib/CodeGen/ExpandLargeFpConvert.cpp
llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-convert-fptosi129.ll
llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-convert-fptoui129.ll
llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-convert-si129tofp.ll
llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-convert-ui129tofp.ll
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/ExpandLargeFpConvert.cpp b/llvm/lib/CodeGen/ExpandLargeFpConvert.cpp
index 4ec966e56d6eef..62135304e859bd 100644
--- a/llvm/lib/CodeGen/ExpandLargeFpConvert.cpp
+++ b/llvm/lib/CodeGen/ExpandLargeFpConvert.cpp
@@ -568,8 +568,29 @@ static void expandIToFP(Instruction *IToFP) {
IToFP->eraseFromParent();
}
+static void scalarize(Instruction *I, SmallVectorImpl<Instruction *> &Replace) {
+ VectorType *VTy = cast<FixedVectorType>(I->getType());
+
+ IRBuilder<> Builder(I);
+
+ unsigned NumElements = VTy->getElementCount().getFixedValue();
+ Value *Result = PoisonValue::get(VTy);
+ for (unsigned Idx = 0; Idx < NumElements; ++Idx) {
+ Value *Ext = Builder.CreateExtractElement(I->getOperand(0), Idx);
+ Value *Cast = Builder.CreateCast(cast<CastInst>(I)->getOpcode(), Ext,
+ I->getType()->getScalarType());
+ Result = Builder.CreateInsertElement(Result, Cast, Idx);
+ if (isa<Instruction>(Cast))
+ Replace.push_back(cast<Instruction>(Cast));
+ }
+ I->replaceAllUsesWith(Result);
+ I->dropAllReferences();
+ I->eraseFromParent();
+}
+
static bool runImpl(Function &F, const TargetLowering &TLI) {
SmallVector<Instruction *, 4> Replace;
+ SmallVector<Instruction *, 4> ReplaceVector;
bool Modified = false;
unsigned MaxLegalFpConvertBitWidth =
@@ -584,29 +605,36 @@ static bool runImpl(Function &F, const TargetLowering &TLI) {
switch (I.getOpcode()) {
case Instruction::FPToUI:
case Instruction::FPToSI: {
- // TODO: This pass doesn't handle vectors.
- if (I.getOperand(0)->getType()->isVectorTy())
+ // TODO: This pass doesn't handle scalable vectors.
+ if (I.getOperand(0)->getType()->isScalableTy())
continue;
- auto *IntTy = dyn_cast<IntegerType>(I.getType());
+ auto *IntTy = dyn_cast<IntegerType>(I.getType()->getScalarType());
if (IntTy->getIntegerBitWidth() <= MaxLegalFpConvertBitWidth)
continue;
- Replace.push_back(&I);
+ if (I.getOperand(0)->getType()->isVectorTy())
+ ReplaceVector.push_back(&I);
+ else
+ Replace.push_back(&I);
Modified = true;
break;
}
case Instruction::UIToFP:
case Instruction::SIToFP: {
- // TODO: This pass doesn't handle vectors.
- if (I.getOperand(0)->getType()->isVectorTy())
+ // TODO: This pass doesn't handle scalable vectors.
+ if (I.getOperand(0)->getType()->isScalableTy())
continue;
- auto *IntTy = dyn_cast<IntegerType>(I.getOperand(0)->getType());
+ auto *IntTy =
+ dyn_cast<IntegerType>(I.getOperand(0)->getType()->getScalarType());
if (IntTy->getIntegerBitWidth() <= MaxLegalFpConvertBitWidth)
continue;
- Replace.push_back(&I);
+ if (I.getOperand(0)->getType()->isVectorTy())
+ ReplaceVector.push_back(&I);
+ else
+ Replace.push_back(&I);
Modified = true;
break;
}
@@ -615,6 +643,11 @@ static bool runImpl(Function &F, const TargetLowering &TLI) {
}
}
+ while (!ReplaceVector.empty()) {
+ Instruction *I = ReplaceVector.pop_back_val();
+ scalarize(I, Replace);
+ }
+
if (Replace.empty())
return false;
diff --git a/llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-convert-fptosi129.ll b/llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-convert-fptosi129.ll
index 75130c27f47376..e058c5bb4aa05b 100644
--- a/llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-convert-fptosi129.ll
+++ b/llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-convert-fptosi129.ll
@@ -176,3 +176,80 @@ define i129 @fp128tosi129(fp128 %a) {
%conv = fptosi fp128 %a to i129
ret i129 %conv
}
+
+define <2 x i129> @floattosi129v2(<2 x float> %a) {
+; CHECK-LABEL: @floattosi129v2(
+; CHECK-NEXT: fp-to-i-entryfp-to-i-entry:
+; CHECK-NEXT: [[TMP0:%.*]] = extractelement <2 x float> [[A:%.*]], i64 0
+; CHECK-NEXT: [[TMP1:%.*]] = bitcast float [[TMP0]] to i32
+; CHECK-NEXT: [[TMP2:%.*]] = zext i32 [[TMP1]] to i129
+; CHECK-NEXT: [[TMP3:%.*]] = icmp sgt i32 [[TMP1]], -1
+; CHECK-NEXT: [[TMP4:%.*]] = select i1 [[TMP3]], i129 1, i129 -1
+; CHECK-NEXT: [[TMP5:%.*]] = lshr i129 [[TMP2]], 23
+; CHECK-NEXT: [[TMP6:%.*]] = and i129 [[TMP5]], 255
+; CHECK-NEXT: [[TMP7:%.*]] = and i129 [[TMP2]], 8388607
+; CHECK-NEXT: [[TMP8:%.*]] = or i129 [[TMP7]], 8388608
+; CHECK-NEXT: [[TMP9:%.*]] = icmp ult i129 [[TMP6]], 127
+; CHECK-NEXT: br i1 [[TMP9]], label [[FP_TO_I_CLEANUP1:%.*]], label [[FP_TO_I_IF_END2:%.*]]
+; CHECK: fp-to-i-if-end2:
+; CHECK-NEXT: [[TMP10:%.*]] = add i129 [[TMP6]], -256
+; CHECK-NEXT: [[TMP11:%.*]] = icmp ult i129 [[TMP10]], -129
+; CHECK-NEXT: br i1 [[TMP11]], label [[FP_TO_I_IF_THEN53:%.*]], label [[FP_TO_I_IF_END94:%.*]]
+; CHECK: fp-to-i-if-then53:
+; CHECK-NEXT: [[TMP12:%.*]] = select i1 [[TMP3]], i129 340282366920938463463374607431768211455, i129 -340282366920938463463374607431768211456
+; CHECK-NEXT: br label [[FP_TO_I_CLEANUP1]]
+; CHECK: fp-to-i-if-end94:
+; CHECK-NEXT: [[TMP13:%.*]] = icmp ult i129 [[TMP6]], 150
+; CHECK-NEXT: br i1 [[TMP13]], label [[FP_TO_I_IF_THEN125:%.*]], label [[FP_TO_I_IF_ELSE6:%.*]]
+; CHECK: fp-to-i-if-then125:
+; CHECK-NEXT: [[TMP14:%.*]] = sub i129 150, [[TMP6]]
+; CHECK-NEXT: [[TMP15:%.*]] = lshr i129 [[TMP8]], [[TMP14]]
+; CHECK-NEXT: [[TMP16:%.*]] = mul i129 [[TMP15]], [[TMP4]]
+; CHECK-NEXT: br label [[FP_TO_I_CLEANUP1]]
+; CHECK: fp-to-i-if-else6:
+; CHECK-NEXT: [[TMP17:%.*]] = add i129 [[TMP6]], -150
+; CHECK-NEXT: [[TMP18:%.*]] = shl i129 [[TMP8]], [[TMP17]]
+; CHECK-NEXT: [[TMP19:%.*]] = mul i129 [[TMP18]], [[TMP4]]
+; CHECK-NEXT: br label [[FP_TO_I_CLEANUP1]]
+; CHECK: fp-to-i-cleanup1:
+; CHECK-NEXT: [[TMP20:%.*]] = phi i129 [ [[TMP12]], [[FP_TO_I_IF_THEN53]] ], [ [[TMP16]], [[FP_TO_I_IF_THEN125]] ], [ [[TMP19]], [[FP_TO_I_IF_ELSE6]] ], [ 0, [[FP_TO_I_ENTRYFP_TO_I_ENTRY:%.*]] ]
+; CHECK-NEXT: [[TMP21:%.*]] = insertelement <2 x i129> poison, i129 [[TMP20]], i64 0
+; CHECK-NEXT: [[TMP22:%.*]] = extractelement <2 x float> [[A]], i64 1
+; CHECK-NEXT: [[TMP23:%.*]] = bitcast float [[TMP22]] to i32
+; CHECK-NEXT: [[TMP24:%.*]] = zext i32 [[TMP23]] to i129
+; CHECK-NEXT: [[TMP25:%.*]] = icmp sgt i32 [[TMP23]], -1
+; CHECK-NEXT: [[TMP26:%.*]] = select i1 [[TMP25]], i129 1, i129 -1
+; CHECK-NEXT: [[TMP27:%.*]] = lshr i129 [[TMP24]], 23
+; CHECK-NEXT: [[TMP28:%.*]] = and i129 [[TMP27]], 255
+; CHECK-NEXT: [[TMP29:%.*]] = and i129 [[TMP24]], 8388607
+; CHECK-NEXT: [[TMP30:%.*]] = or i129 [[TMP29]], 8388608
+; CHECK-NEXT: [[TMP31:%.*]] = icmp ult i129 [[TMP28]], 127
+; CHECK-NEXT: br i1 [[TMP31]], label [[FP_TO_I_CLEANUP:%.*]], label [[FP_TO_I_IF_END:%.*]]
+; CHECK: fp-to-i-if-end:
+; CHECK-NEXT: [[TMP32:%.*]] = add i129 [[TMP28]], -256
+; CHECK-NEXT: [[TMP33:%.*]] = icmp ult i129 [[TMP32]], -129
+; CHECK-NEXT: br i1 [[TMP33]], label [[FP_TO_I_IF_THEN5:%.*]], label [[FP_TO_I_IF_END9:%.*]]
+; CHECK: fp-to-i-if-then5:
+; CHECK-NEXT: [[TMP34:%.*]] = select i1 [[TMP25]], i129 340282366920938463463374607431768211455, i129 -340282366920938463463374607431768211456
+; CHECK-NEXT: br label [[FP_TO_I_CLEANUP]]
+; CHECK: fp-to-i-if-end9:
+; CHECK-NEXT: [[TMP35:%.*]] = icmp ult i129 [[TMP28]], 150
+; CHECK-NEXT: br i1 [[TMP35]], label [[FP_TO_I_IF_THEN12:%.*]], label [[FP_TO_I_IF_ELSE:%.*]]
+; CHECK: fp-to-i-if-then12:
+; CHECK-NEXT: [[TMP36:%.*]] = sub i129 150, [[TMP28]]
+; CHECK-NEXT: [[TMP37:%.*]] = lshr i129 [[TMP30]], [[TMP36]]
+; CHECK-NEXT: [[TMP38:%.*]] = mul i129 [[TMP37]], [[TMP26]]
+; CHECK-NEXT: br label [[FP_TO_I_CLEANUP]]
+; CHECK: fp-to-i-if-else:
+; CHECK-NEXT: [[TMP39:%.*]] = add i129 [[TMP28]], -150
+; CHECK-NEXT: [[TMP40:%.*]] = shl i129 [[TMP30]], [[TMP39]]
+; CHECK-NEXT: [[TMP41:%.*]] = mul i129 [[TMP40]], [[TMP26]]
+; CHECK-NEXT: br label [[FP_TO_I_CLEANUP]]
+; CHECK: fp-to-i-cleanup:
+; CHECK-NEXT: [[TMP42:%.*]] = phi i129 [ [[TMP34]], [[FP_TO_I_IF_THEN5]] ], [ [[TMP38]], [[FP_TO_I_IF_THEN12]] ], [ [[TMP41]], [[FP_TO_I_IF_ELSE]] ], [ 0, [[FP_TO_I_CLEANUP1]] ]
+; CHECK-NEXT: [[TMP43:%.*]] = insertelement <2 x i129> [[TMP21]], i129 [[TMP42]], i64 1
+; CHECK-NEXT: ret <2 x i129> [[TMP43]]
+;
+ %conv = fptosi <2 x float> %a to <2 x i129>
+ ret <2 x i129> %conv
+}
diff --git a/llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-convert-fptoui129.ll b/llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-convert-fptoui129.ll
index ed630d7934c3a8..c699f805754cc1 100644
--- a/llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-convert-fptoui129.ll
+++ b/llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-convert-fptoui129.ll
@@ -176,3 +176,80 @@ define i129 @fp128toui129(fp128 %a) {
%conv = fptoui fp128 %a to i129
ret i129 %conv
}
+
+define <2 x i129> @floattoui129v2(<2 x float> %a) {
+; CHECK-LABEL: @floattoui129v2(
+; CHECK-NEXT: fp-to-i-entryfp-to-i-entry:
+; CHECK-NEXT: [[TMP0:%.*]] = extractelement <2 x float> [[A:%.*]], i64 0
+; CHECK-NEXT: [[TMP1:%.*]] = bitcast float [[TMP0]] to i32
+; CHECK-NEXT: [[TMP2:%.*]] = zext i32 [[TMP1]] to i129
+; CHECK-NEXT: [[TMP3:%.*]] = icmp sgt i32 [[TMP1]], -1
+; CHECK-NEXT: [[TMP4:%.*]] = select i1 [[TMP3]], i129 1, i129 -1
+; CHECK-NEXT: [[TMP5:%.*]] = lshr i129 [[TMP2]], 23
+; CHECK-NEXT: [[TMP6:%.*]] = and i129 [[TMP5]], 255
+; CHECK-NEXT: [[TMP7:%.*]] = and i129 [[TMP2]], 8388607
+; CHECK-NEXT: [[TMP8:%.*]] = or i129 [[TMP7]], 8388608
+; CHECK-NEXT: [[TMP9:%.*]] = icmp ult i129 [[TMP6]], 127
+; CHECK-NEXT: br i1 [[TMP9]], label [[FP_TO_I_CLEANUP1:%.*]], label [[FP_TO_I_IF_END2:%.*]]
+; CHECK: fp-to-i-if-end2:
+; CHECK-NEXT: [[TMP10:%.*]] = add i129 [[TMP6]], -256
+; CHECK-NEXT: [[TMP11:%.*]] = icmp ult i129 [[TMP10]], -129
+; CHECK-NEXT: br i1 [[TMP11]], label [[FP_TO_I_IF_THEN53:%.*]], label [[FP_TO_I_IF_END94:%.*]]
+; CHECK: fp-to-i-if-then53:
+; CHECK-NEXT: [[TMP12:%.*]] = select i1 [[TMP3]], i129 340282366920938463463374607431768211455, i129 -340282366920938463463374607431768211456
+; CHECK-NEXT: br label [[FP_TO_I_CLEANUP1]]
+; CHECK: fp-to-i-if-end94:
+; CHECK-NEXT: [[TMP13:%.*]] = icmp ult i129 [[TMP6]], 150
+; CHECK-NEXT: br i1 [[TMP13]], label [[FP_TO_I_IF_THEN125:%.*]], label [[FP_TO_I_IF_ELSE6:%.*]]
+; CHECK: fp-to-i-if-then125:
+; CHECK-NEXT: [[TMP14:%.*]] = sub i129 150, [[TMP6]]
+; CHECK-NEXT: [[TMP15:%.*]] = lshr i129 [[TMP8]], [[TMP14]]
+; CHECK-NEXT: [[TMP16:%.*]] = mul i129 [[TMP15]], [[TMP4]]
+; CHECK-NEXT: br label [[FP_TO_I_CLEANUP1]]
+; CHECK: fp-to-i-if-else6:
+; CHECK-NEXT: [[TMP17:%.*]] = add i129 [[TMP6]], -150
+; CHECK-NEXT: [[TMP18:%.*]] = shl i129 [[TMP8]], [[TMP17]]
+; CHECK-NEXT: [[TMP19:%.*]] = mul i129 [[TMP18]], [[TMP4]]
+; CHECK-NEXT: br label [[FP_TO_I_CLEANUP1]]
+; CHECK: fp-to-i-cleanup1:
+; CHECK-NEXT: [[TMP20:%.*]] = phi i129 [ [[TMP12]], [[FP_TO_I_IF_THEN53]] ], [ [[TMP16]], [[FP_TO_I_IF_THEN125]] ], [ [[TMP19]], [[FP_TO_I_IF_ELSE6]] ], [ 0, [[FP_TO_I_ENTRYFP_TO_I_ENTRY:%.*]] ]
+; CHECK-NEXT: [[TMP21:%.*]] = insertelement <2 x i129> poison, i129 [[TMP20]], i64 0
+; CHECK-NEXT: [[TMP22:%.*]] = extractelement <2 x float> [[A]], i64 1
+; CHECK-NEXT: [[TMP23:%.*]] = bitcast float [[TMP22]] to i32
+; CHECK-NEXT: [[TMP24:%.*]] = zext i32 [[TMP23]] to i129
+; CHECK-NEXT: [[TMP25:%.*]] = icmp sgt i32 [[TMP23]], -1
+; CHECK-NEXT: [[TMP26:%.*]] = select i1 [[TMP25]], i129 1, i129 -1
+; CHECK-NEXT: [[TMP27:%.*]] = lshr i129 [[TMP24]], 23
+; CHECK-NEXT: [[TMP28:%.*]] = and i129 [[TMP27]], 255
+; CHECK-NEXT: [[TMP29:%.*]] = and i129 [[TMP24]], 8388607
+; CHECK-NEXT: [[TMP30:%.*]] = or i129 [[TMP29]], 8388608
+; CHECK-NEXT: [[TMP31:%.*]] = icmp ult i129 [[TMP28]], 127
+; CHECK-NEXT: br i1 [[TMP31]], label [[FP_TO_I_CLEANUP:%.*]], label [[FP_TO_I_IF_END:%.*]]
+; CHECK: fp-to-i-if-end:
+; CHECK-NEXT: [[TMP32:%.*]] = add i129 [[TMP28]], -256
+; CHECK-NEXT: [[TMP33:%.*]] = icmp ult i129 [[TMP32]], -129
+; CHECK-NEXT: br i1 [[TMP33]], label [[FP_TO_I_IF_THEN5:%.*]], label [[FP_TO_I_IF_END9:%.*]]
+; CHECK: fp-to-i-if-then5:
+; CHECK-NEXT: [[TMP34:%.*]] = select i1 [[TMP25]], i129 340282366920938463463374607431768211455, i129 -340282366920938463463374607431768211456
+; CHECK-NEXT: br label [[FP_TO_I_CLEANUP]]
+; CHECK: fp-to-i-if-end9:
+; CHECK-NEXT: [[TMP35:%.*]] = icmp ult i129 [[TMP28]], 150
+; CHECK-NEXT: br i1 [[TMP35]], label [[FP_TO_I_IF_THEN12:%.*]], label [[FP_TO_I_IF_ELSE:%.*]]
+; CHECK: fp-to-i-if-then12:
+; CHECK-NEXT: [[TMP36:%.*]] = sub i129 150, [[TMP28]]
+; CHECK-NEXT: [[TMP37:%.*]] = lshr i129 [[TMP30]], [[TMP36]]
+; CHECK-NEXT: [[TMP38:%.*]] = mul i129 [[TMP37]], [[TMP26]]
+; CHECK-NEXT: br label [[FP_TO_I_CLEANUP]]
+; CHECK: fp-to-i-if-else:
+; CHECK-NEXT: [[TMP39:%.*]] = add i129 [[TMP28]], -150
+; CHECK-NEXT: [[TMP40:%.*]] = shl i129 [[TMP30]], [[TMP39]]
+; CHECK-NEXT: [[TMP41:%.*]] = mul i129 [[TMP40]], [[TMP26]]
+; CHECK-NEXT: br label [[FP_TO_I_CLEANUP]]
+; CHECK: fp-to-i-cleanup:
+; CHECK-NEXT: [[TMP42:%.*]] = phi i129 [ [[TMP34]], [[FP_TO_I_IF_THEN5]] ], [ [[TMP38]], [[FP_TO_I_IF_THEN12]] ], [ [[TMP41]], [[FP_TO_I_IF_ELSE]] ], [ 0, [[FP_TO_I_CLEANUP1]] ]
+; CHECK-NEXT: [[TMP43:%.*]] = insertelement <2 x i129> [[TMP21]], i129 [[TMP42]], i64 1
+; CHECK-NEXT: ret <2 x i129> [[TMP43]]
+;
+ %conv = fptoui <2 x float> %a to <2 x i129>
+ ret <2 x i129> %conv
+}
diff --git a/llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-convert-si129tofp.ll b/llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-convert-si129tofp.ll
index 76f5248302badc..f70ce2f85f65bd 100644
--- a/llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-convert-si129tofp.ll
+++ b/llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-convert-si129tofp.ll
@@ -426,3 +426,166 @@ define fp128 @si129tofp128(i129 %a) {
%conv = sitofp i129 %a to fp128
ret fp128 %conv
}
+
+define <2 x float> @si129tofloatv2(<2 x i129> %a) {
+; CHECK-LABEL: @si129tofloatv2(
+; CHECK-NEXT: itofp-entryitofp-entry:
+; CHECK-NEXT: [[TMP0:%.*]] = extractelement <2 x i129> [[A:%.*]], i64 0
+; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i129 [[TMP0]], 0
+; CHECK-NEXT: br i1 [[TMP1]], label [[ITOFP_RETURN1:%.*]], label [[ITOFP_IF_END2:%.*]]
+; CHECK: itofp-if-end2:
+; CHECK-NEXT: [[TMP2:%.*]] = ashr i129 [[TMP0]], 128
+; CHECK-NEXT: [[TMP3:%.*]] = xor i129 [[TMP2]], [[TMP0]]
+; CHECK-NEXT: [[TMP4:%.*]] = sub i129 [[TMP3]], [[TMP2]]
+; CHECK-NEXT: [[TMP5:%.*]] = call i129 @llvm.ctlz.i129(i129 [[TMP4]], i1 true)
+; CHECK-NEXT: [[TMP6:%.*]] = trunc i129 [[TMP5]] to i32
+; CHECK-NEXT: [[TMP7:%.*]] = sub i32 129, [[TMP6]]
+; CHECK-NEXT: [[TMP8:%.*]] = sub i32 128, [[TMP6]]
+; CHECK-NEXT: [[TMP9:%.*]] = icmp sgt i32 [[TMP7]], 24
+; CHECK-NEXT: br i1 [[TMP9]], label [[ITOFP_IF_THEN43:%.*]], label [[ITOFP_IF_ELSE8:%.*]]
+; CHECK: itofp-if-then43:
+; CHECK-NEXT: switch i32 [[TMP7]], label [[ITOFP_SW_DEFAULT5:%.*]] [
+; CHECK-NEXT: i32 25, label [[ITOFP_SW_BB4:%.*]]
+; CHECK-NEXT: i32 26, label [[ITOFP_SW_EPILOG6:%.*]]
+; CHECK-NEXT: ]
+; CHECK: itofp-sw-bb4:
+; CHECK-NEXT: [[TMP10:%.*]] = shl i129 [[TMP4]], 1
+; CHECK-NEXT: br label [[ITOFP_SW_EPILOG6]]
+; CHECK: itofp-sw-default5:
+; CHECK-NEXT: [[TMP11:%.*]] = sub i32 103, [[TMP6]]
+; CHECK-NEXT: [[TMP12:%.*]] = zext i32 [[TMP11]] to i129
+; CHECK-NEXT: [[TMP13:%.*]] = lshr i129 [[TMP4]], [[TMP12]]
+; CHECK-NEXT: [[TMP14:%.*]] = add i32 [[TMP6]], 26
+; CHECK-NEXT: [[TMP15:%.*]] = zext i32 [[TMP14]] to i129
+; CHECK-NEXT: [[TMP16:%.*]] = lshr i129 -1, [[TMP15]]
+; CHECK-NEXT: [[TMP17:%.*]] = and i129 [[TMP16]], [[TMP4]]
+; CHECK-NEXT: [[TMP18:%.*]] = icmp ne i129 [[TMP17]], 0
+; CHECK-NEXT: [[TMP19:%.*]] = zext i1 [[TMP18]] to i129
+; CHECK-NEXT: [[TMP20:%.*]] = or i129 [[TMP13]], [[TMP19]]
+; CHECK-NEXT: br label [[ITOFP_SW_EPILOG6]]
+; CHECK: itofp-sw-epilog6:
+; CHECK-NEXT: [[TMP21:%.*]] = phi i129 [ [[TMP20]], [[ITOFP_SW_DEFAULT5]] ], [ [[TMP4]], [[ITOFP_IF_THEN43]] ], [ [[TMP10]], [[ITOFP_SW_BB4]] ]
+; CHECK-NEXT: [[TMP22:%.*]] = trunc i129 [[TMP21]] to i32
+; CHECK-NEXT: [[TMP23:%.*]] = lshr i32 [[TMP22]], 2
+; CHECK-NEXT: [[TMP24:%.*]] = and i32 [[TMP23]], 1
+; CHECK-NEXT: [[TMP25:%.*]] = zext i32 [[TMP24]] to i129
+; CHECK-NEXT: [[TMP26:%.*]] = or i129 [[TMP21]], [[TMP25]]
+; CHECK-NEXT: [[TMP27:%.*]] = add i129 [[TMP26]], 1
+; CHECK-NEXT: [[TMP28:%.*]] = ashr i129 [[TMP27]], 2
+; CHECK-NEXT: [[A310:%.*]] = and i129 [[TMP27]], 67108864
+; CHECK-NEXT: [[TMP29:%.*]] = icmp eq i129 [[A310]], 0
+; CHECK-NEXT: [[TMP30:%.*]] = trunc i129 [[TMP28]] to i32
+; CHECK-NEXT: [[TMP31:%.*]] = lshr i129 [[TMP28]], 32
+; CHECK-NEXT: [[TMP32:%.*]] = trunc i129 [[TMP31]] to i32
+; CHECK-NEXT: br i1 [[TMP29]], label [[ITOFP_IF_END269:%.*]], label [[ITOFP_IF_THEN207:%.*]]
+; CHECK: itofp-if-then207:
+; CHECK-NEXT: [[TMP33:%.*]] = ashr i129 [[TMP27]], 3
+; CHECK-NEXT: [[TMP34:%.*]] = trunc i129 [[TMP33]] to i32
+; CHECK-NEXT: [[TMP35:%.*]] = lshr i129 [[TMP33]], 32
+; CHECK-NEXT: [[TMP36:%.*]] = trunc i129 [[TMP35]] to i32
+; CHECK-NEXT: br label [[ITOFP_IF_END269]]
+; CHECK: itofp-if-else8:
+; CHECK-NEXT: [[TMP37:%.*]] = add i32 [[TMP6]], -105
+; CHECK-NEXT: [[TMP38:%.*]] = zext i32 [[TMP37]] to i129
+; CHECK-NEXT: [[TMP39:%.*]] = shl i129 [[TMP4]], [[TMP38]]
+; CHECK-NEXT: [[TMP40:%.*]] = trunc i129 [[TMP39]] to i32
+; CHECK-NEXT: [[TMP41:%.*]] = lshr i129 [[TMP39]], 32
+; CHECK-NEXT: [[TMP42:%.*]] = trunc i129 [[TMP41]] to i32
+; CHECK-NEXT: br label [[ITOFP_IF_END269]]
+; CHECK: itofp-if-end269:
+; CHECK-NEXT: [[TMP43:%.*]] = phi i32 [ [[TMP34]], [[ITOFP_IF_THEN207]] ], [ [[TMP30]], [[ITOFP_SW_EPILOG6]] ], [ [[TMP40]], [[ITOFP_IF_ELSE8]] ]
+; CHECK-NEXT: [[TMP44:%.*]] = phi i32 [ [[TMP7]], [[ITOFP_IF_THEN207]] ], [ [[TMP8]], [[ITOFP_SW_EPILOG6]] ], [ [[TMP8]], [[ITOFP_IF_ELSE8]] ]
+; CHECK-NEXT: [[TMP45:%.*]] = trunc i129 [[TMP2]] to i32
+; CHECK-NEXT: [[TMP46:%.*]] = and i32 [[TMP45]], -2147483648
+; CHECK-NEXT: [[TMP47:%.*]] = shl i32 [[TMP44]], 23
+; CHECK-NEXT: [[TMP48:%.*]] = add i32 [[TMP47]], 1065353216
+; CHECK-NEXT: [[TMP49:%.*]] = and i32 [[TMP43]], 8388607
+; CHECK-NEXT: [[TMP50:%.*]] = or i32 [[TMP49]], [[TMP46]]
+; CHECK-NEXT: [[TMP51:%.*]] = or i32 [[TMP50]], [[TMP48]]
+; CHECK-NEXT: [[TMP52:%.*]] = bitcast i32 [[TMP51]] to float
+; CHECK-NEXT: br label [[ITOFP_RETURN1]]
+; CHECK: itofp-return1:
+; CHECK-NEXT: [[TMP53:%.*]] = phi float [ [[TMP52]], [[ITOFP_IF_END269]] ], [ 0.000000e+00, [[ITOFP_ENTRYITOFP_ENTRY:%.*]] ]
+; CHECK-NEXT: [[TMP54:%.*]] = insertelement <2 x float> poison, float [[TMP53]], i64 0
+; CHECK-NEXT: [[TMP55:%.*]] = extractelement <2 x i129> [[A]], i64 1
+; CHECK-NEXT: [[TMP56:%.*]] = icmp eq i129 [[TMP55]], 0
+; CHECK-NEXT: br i1 [[TMP56]], label [[ITOFP_RETURN:%.*]], label [[ITOFP_IF_END:%.*]]
+; CHECK: itofp-if-end:
+; CHECK-NEXT: [[TMP57:%.*]] = ashr i129 [[TMP55]], 128
+; CHECK-NEXT: [[TMP58:%.*]] = xor i129 [[TMP57]], [[TMP55]]
+; CHECK-NEXT: [[TMP59:%.*]] = sub i129 [[TMP58]], [[TMP57]]
+; CHECK-NEXT: [[TMP60:%.*]] = call i129 @llvm.ctlz.i129(i129 [[TMP59]], i1 true)
+; CHECK-NEXT: [[TMP61:%.*]] = trunc i129 [[TMP60]] to i32
+; CHECK-NEXT: [[TMP62:%.*]] = sub i32 129, [[TMP61]]
+; CHECK-NEXT: [[TMP63:%.*]] = sub i32 128, [[TMP61]]
+; CHECK-NEXT: [[TMP64:%.*]] = icmp sgt i32 [[TMP62]], 24
+; CHECK-NEXT: br i1 [[TMP64]], label [[ITOFP_IF_THEN4:%.*]], label [[ITOFP_IF_ELSE:%.*]]
+; CHECK: itofp-if-then4:
+; CHECK-NEXT: switch i32 [[TMP62]], label [[ITOFP_SW_DEFAULT:%.*]] [
+; CHECK-NEXT: i32 25, label [[ITOFP_SW_BB:%.*]]
+; CHECK-NEXT: i32 26, label [[ITOFP_SW_EPILOG:%.*]]
+; CHECK-NEXT: ]
+; CHECK: itofp-sw-bb:
+; CHECK-NEXT: [[TMP65:%.*]] = shl i129 [[TMP59]], 1
+; CHECK-NEXT: br label [[ITOFP_SW_EPILOG]]
+; CHECK: itofp-sw-default:
+; CHECK-NEXT: [[TMP66:%.*]] = sub i32 103, [[TMP61]]
+; CHECK-NEXT: [[TMP67:%.*]] = zext i32 [[TMP66]] to i129
+; CHECK-NEXT: [[TMP68:%.*]] = lshr i129 [[TMP59]], [[TMP67]]
+; CHECK-NEXT: [[TMP69:%.*]] = add i32 [[TMP61]], 26
+; CHECK-NEXT: [[TMP70:%.*]] = zext i32 [[TMP69]] to i129
+; CHECK-NEXT: [[TMP71:%.*]] = lshr i129 -1, [[TMP70]]
+; CHECK-NEXT: [[TMP72:%.*]] = and i129 [[TMP71]], [[TMP59]]
+; CHECK-NEXT: [[TMP73:%.*]] = icmp ne i129 [[TMP72]], 0
+; CHECK-NEXT: [[TMP74:%.*]] = zext i1 [[TMP73]] to i129
+; CHECK-NEXT: [[TMP75:%.*]] = or i129 [[TMP68]], [[TMP74]]
+; CHECK-NEXT: br label [[ITOFP_SW_EPILOG]]
+; CHECK: itofp-sw-epilog:
+; CHECK-NEXT: [[TMP76:%.*]] = phi i129 [ [[TMP75]], [[ITOFP_SW_DEFAULT]] ], [ [[TMP59]], [[ITOFP_IF_THEN4]] ], [ [[TMP65]], [[ITOFP_SW_BB]] ]
+; CHECK-NEXT: [[TMP77:%.*]] = trunc i129 [[TMP76]] to i32
+; CHECK-NEXT: [[TMP78:%.*]] = lshr i32 [[TMP77]], 2
+; CHECK-NEXT: [[TMP79:%.*]] = and i32 [[TMP78]], 1
+; CHECK-NEXT: [[TMP80:%.*]] = zext i32 [[TMP79]] to i129
+; CHECK-NEXT: [[TMP81:%.*]] = or i129 [[TMP76]], [[TMP80]]
+; CHECK-NEXT: [[TMP82:%.*]] = add i129 [[TMP81]], 1
+; CHECK-NEXT: [[TMP83:%.*]] = ashr i129 [[TMP82]], 2
+; CHECK-NEXT: [[A3:%.*]] = and i129 [[TMP82]], 67108864
+; CHECK-NEXT: [[TMP84:%.*]] = icmp eq i129 [[A3]], 0
+; CHECK-NEXT: [[TMP85:%.*]] = trunc i129 [[TMP83]] to i32
+; CHECK-NEXT: [[TMP86:%.*]] = lshr i129 [[TMP83]], 32
+; CHECK-NEXT: [[TMP87:%.*]] = trunc i129 [[TMP86]] to i32
+; CHECK-NEXT: br i1 [[TMP84]], label [[ITOFP_IF_END26:%.*]], label [[ITOFP_IF_THEN20:%.*]]
+; CHECK: itofp-if-then20:
+; CHECK-NEXT: [[TMP88:%.*]] = ashr i129 [[TMP82]], 3
+; CHECK-NEXT: [[TMP89:%.*]] = trunc i129 [[TMP88]] to i32
+; CHECK-NEXT: [[TMP90:%.*]] = lshr i129 [[TMP88]], 32
+; CHECK-NEXT: [[TMP91:%.*]] = trunc i129 [[TMP90]] to i32
+; CHECK-NEXT: br label [[ITOFP_IF_END26]]
+; CHECK: itofp-if-else:
+; CHECK-NEXT: [[TMP92:%.*]] = add i32 [[TMP61]], -105
+; CHECK-NEXT: [[TMP93:%.*]] = zext i32 [[TMP92]] to i129
+; CHECK-NEXT: [[TMP94:%.*]] = shl i129 [[TMP59]], [[TMP93]]
+; CHECK-NEXT: [[TMP95:%.*]] = trunc i129 [[TMP94]] to i32
+; CHECK-NEXT: [[TMP96:%.*]] = lshr i129 [[TMP94]], 32
+; CHECK-NEXT: [[TMP97:%.*]] = trunc i129 [[TMP96]] to i32
+; CHECK-NEXT: br label [[ITOFP_IF_END26]]
+; CHECK: itofp-if-end26:
+; CHECK-NEXT: [[TMP98:%.*]] = phi i32 [ [[TMP89]], [[ITOFP_IF_THEN20]] ], [ [[TMP85]], [[ITOFP_SW_EPILOG]] ], [ [[TMP95]], [[ITOFP_IF_ELSE]] ]
+; CHECK-NEXT: [[TMP99:%.*]] = phi i32 [ [[TMP62]], [[ITOFP_IF_THEN20]] ], [ [[TMP63]], [[ITOFP_SW_EPILOG]] ], [ [[TMP63]], [[ITOFP_IF_ELSE]] ]
+; CHECK-NEXT: [[TMP100:%.*]] = trunc i129 [[TMP57]] to i32
+; CHECK-NEXT: [[TMP101:%.*]] = and i32 [[TMP100]], -2147483648
+; CHECK-NEXT: [[TMP102:%.*]] = shl i32 [[TMP99]], 23
+; CHECK-NEXT: [[TMP103:%.*]] = add i32 [[TMP102]], 1065353216
+; CHECK-NEXT: [[TMP104:%.*]] = and i32 [[TMP98]], 8388607
+; CHECK-NEXT: [[TMP105:%.*]] = or i32 [[TMP104]], [[TMP101]]
+; CHECK-NEXT: [[TMP106:%.*]] = or i32 [[TMP105]], [[TMP103]]
+; CHECK-NEXT: [[TMP107:%.*]] = bitcast i32 [[TMP106]] to float
+; CHECK-NEXT: br label [[ITOFP_RETURN]]
+; CHECK: itofp-return:
+; CHECK-NEXT: [[TMP108:%.*]] = phi float [ [[TMP107]], [[ITOFP_IF_END26]] ], [ 0.000000e+00, [[ITOFP_RETURN1]] ]
+; CHECK-NEXT: [[TMP109:%.*]] = insertelement <2 x float> [[TMP54]], float [[TMP108]], i64 1
+; CHECK-NEXT: ret <2 x float> [[TMP109]]
+;
+ %conv = sitofp <2 x i129> %a to <2 x float>
+ ret <2 x float> %conv
+}
diff --git a/llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-convert-ui129tofp.ll b/llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-convert-ui129tofp.ll
index 96d87a5cace98b..ee54d53e9ba03a 100644
--- a/llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-convert-ui129tofp.ll
+++ b/llvm/test/Transforms/ExpandLargeFpConvert/X86/expand-large-fp-convert-ui129tofp.ll
@@ -426,3 +426,166 @@ define fp128 @ui129tofp128(i129 %a) {
%conv = uitofp i129 %a to fp128
ret fp128 %conv
}
+
+define <2 x float> @ui129tofloatv2(<2 x i129> %a) {
+; CHECK-LABEL: @ui129tofloatv2(
+; CHECK-NEXT: itofp-entryitofp-entry:
+; CHECK-NEXT: [[TMP0:%.*]] = extractelement <2 x i129> [[A:%.*]], i64 0
+; CHECK-NEXT: [[TMP1:%.*]] = icmp eq i129 [[TMP0]], 0
+; CHECK-NEXT: br i1 [[TMP1]], label [[ITOFP_RETURN1:%.*]], label [[ITOFP_IF_END2:%.*]]
+; CHECK: itofp-if-end2:
+; CHECK-NEXT: [[TMP2:%.*]] = ashr i129 [[TMP0]], 128
+; CHECK-NEXT: [[TMP3:%.*]] = xor i129 [[TMP2]], [[TMP0]]
+; CHECK-NEXT: [[TMP4:%.*]] = sub i129 [[TMP3]], [[TMP2]]
+; CHECK-NEXT: [[TMP5:%.*]] = call i129 @llvm.ctlz.i129(i129 [[TMP0]], i1 true)
+; CHECK-NEXT: [[TMP6:%.*]] = trunc i129 [[TMP5]] to i32
+; CHECK-NEXT: [[TMP7:%.*]] = sub i32 129, [[TMP6]]
+; CHECK-NEXT: [[TMP8:%.*]] = sub i32 128, [[TMP6]]
+; CHECK-NEXT: [[TMP9:%.*]] = icmp sgt i32 [[TMP7]], 24
+; CHECK-NEXT: br i1 [[TMP9]], label [[ITOFP_IF_THEN43:%.*]], label [[ITOFP_IF_ELSE8:%.*]]
+; CHECK: itofp-if-then43:
+; CHECK-NEXT: switch i32 [[TMP7]], label [[ITOFP_SW_DEFAULT5:%.*]] [
+; CHECK-NEXT: i32 25, label [[ITOFP_SW_BB4:%.*]]
+; CHECK-NEXT: i32 26, label [[ITOFP_SW_EPILOG6:%.*]]
+; CHECK-NEXT: ]
+; CHECK: itofp-sw-bb4:
+; CHECK-NEXT: [[TMP10:%.*]] = shl i129 [[TMP0]], 1
+; CHECK-NEXT: br label [[ITOFP_SW_EPILOG6]]
+; CHECK: itofp-sw-default5:
+; CHECK-NEXT: [[TMP11:%.*]] = sub i32 103, [[TMP6]]
+; CHECK-NEXT: [[TMP12:%.*]] = zext i32 [[TMP11]] to i129
+; CHECK-NEXT: [[TMP13:%.*]] = lshr i129 [[TMP0]], [[TMP12]]
+; CHECK-NEXT: [[TMP14:%.*]] = add i32 [[TMP6]], 26
+; CHECK-NEXT: [[TMP15:%.*]] = zext i32 [[TMP14]] to i129
+; CHECK-NEXT: [[TMP16:%.*]] = lshr i129 -1, [[TMP15]]
+; CHECK-NEXT: [[TMP17:%.*]] = and i129 [[TMP16]], [[TMP0]]
+; CHECK-NEXT: [[TMP18:%.*]] = icmp ne i129 [[TMP17]], 0
+; CHECK-NEXT: [[TMP19:%.*]] = zext i1 [[TMP18]] to i129
+; CHECK-NEXT: [[TMP20:%.*]] = or i129 [[TMP13]], [[TMP19]]
+; CHECK-NEXT: br label [[ITOFP_SW_EPILOG6]]
+; CHECK: itofp-sw-epilog6:
+; CHECK-NEXT: [[TMP21:%.*]] = phi i129 [ [[TMP20]], [[ITOFP_SW_DEFAULT5]] ], [ [[TMP0]], [[ITOFP_IF_THEN43]] ], [ [[TMP10]], [[ITOFP_SW_BB4]] ]
+; CHECK-NEXT: [[TMP22:%.*]] = trunc i129 [[TMP21]] to i32
+; CHECK-NEXT: [[TMP23:%.*]] = lshr i32 [[TMP22]], 2
+; CHECK-NEXT: [[TMP24:%.*]] = and i32 [[TMP23]], 1
+; CHECK-NEXT: [[TMP25:%.*]] = zext i32 [[TMP24]] to i129
+; CHECK-NEXT: [[TMP26:%.*]] = or i129 [[TMP21]], [[TMP25]]
+; CHECK-NEXT: [[TMP27:%.*]] = add i129 [[TMP26]], 1
+; CHECK-NEXT: [[TMP28:%.*]] = lshr i129 [[TMP27]], 2
+; CHECK-NEXT: [[A310:%.*]] = and i129 [[TMP27]], 67108864
+; CHECK-NEXT: [[TMP29:%.*]] = icmp eq i129 [[A310]], 0
+; CHECK-NEXT: [[TMP30:%.*]] = trunc i129 [[TMP28]] to i32
+; CHECK-NEXT: [[TMP31:%.*]] = lshr i129 [[TMP28]], 32
+; CHECK-NEXT: [[TMP32:%.*]] = trunc i129 [[TMP31]] to i32
+; CHECK-NEXT: br i1 [[TMP29]], label [[ITOFP_IF_END269:%.*]], label [[ITOFP_IF_THEN207:%.*]]
+; CHECK: itofp-if-then207:
+; CHECK-NEXT: [[TMP33:%.*]] = lshr i129 [[TMP27]], 3
+; CHECK-NEXT: [[TMP34:%.*]] = trunc i129 [[TMP33]] to i32
+; CHECK-NEXT: [[TMP35:%.*]] = lshr i129 [[TMP33]], 32
+; CHECK-NEXT: [[TMP36:%.*]] = trunc i129 [[TMP35]] to i32
+; CHECK-NEXT: br label [[ITOFP_IF_END269]]
+; CHECK: itofp-if-else8:
+; CHECK-NEXT: [[TMP37:%.*]] = add i32 [[TMP6]], -105
+; CHECK-NEXT: [[TMP38:%.*]] = zext i32 [[TMP37]] to i129
+; CHECK-NEXT: [[TMP39:%.*]] = shl i129 [[TMP0]], [[TMP38]]
+; CHECK-NEXT: [[TMP40:%.*]] = trunc i129 [[TMP39]] to i32
+; CHECK-NEXT: [[TMP41:%.*]] = lshr i129 [[TMP39]], 32
+; CHECK-NEXT: [[TMP42:%.*]] = trunc i129 [[TMP41]] to i32
+; CHECK-NEXT: br label [[ITOFP_IF_END269]]
+; CHECK: itofp-if-end269:
+; CHECK-NEXT: [[TMP43:%.*]] = phi i32 [ [[TMP34]], [[ITOFP_IF_THEN207]] ], [ [[TMP30]], [[ITOFP_SW_EPILOG6]] ], [ [[TMP40]], [[ITOFP_IF_ELSE8]] ]
+; CHECK-NEXT: [[TMP44:%.*]] = phi i32 [ [[TMP7]], [[ITOFP_IF_THEN207]] ], [ [[TMP8]], [[ITOFP_SW_EPILOG6]] ], [ [[TMP8]], [[ITOFP_IF_ELSE8]] ]
+; CHECK-NEXT: [[TMP45:%.*]] = trunc i129 [[TMP2]] to i32
+; CHECK-NEXT: [[TMP46:%.*]] = and i32 [[TMP45]], -2147483648
+; CHECK-NEXT: [[TMP47:%.*]] = shl i32 [[TMP44]], 23
+; CHECK-NEXT: [[TMP48:%.*]] = add i32 [[TMP47]], 1065353216
+; CHECK-NEXT: [[TMP49:%.*]] = and i32 [[TMP43]], 8388607
+; CHECK-NEXT: [[TMP50:%.*]] = or i32 [[TMP49]], [[TMP46]]
+; CHECK-NEXT: [[TMP51:%.*]] = or i32 [[TMP49]], [[TMP48]]
+; CHECK-NEXT: [[TMP52:%.*]] = bitcast i32 [[TMP51]] to float
+; CHECK-NEXT: br label [[ITOFP_RETURN1]]
+; CHECK: itofp-return1:
+; CHECK-NEXT: [[TMP53:%.*]] = phi float [ [[TMP52]], [[ITOFP_IF_END269]] ], [ 0.000000e+00, [[ITOFP_ENTRYITOFP_ENTRY:%.*]] ]
+; CHECK-NEXT: [[TMP54:%.*]] = insertelement <2 x float> poison, float [[TMP53]], i64 0
+; CHECK-NEXT: [[TMP55:%.*]] = extractelement <2 x i129> [[A]], i64 1
+; CHECK-NEXT: [[TMP56:%.*]] = icmp eq i129 [[TMP55]], 0
+; CHECK-NEXT: br i1 [[TMP56]], label [[ITOFP_RETURN:%.*]], label [[ITOFP_IF_END:%.*]]
+; CHECK: itofp-if-end:
+; CHECK-NEXT: [[TMP57:%.*]] = ashr i129 [[TMP55]], 128
+; CHECK-NEXT: [[TMP58:%.*]] = xor i129 [[TMP57]], [[TMP55]]
+; CHECK-NEXT: [[TMP59:%.*]] = sub i129 [[TMP58]], [[TMP57]]
+; CHECK-NEXT: [[TMP60:%.*]] = call i129 @llvm.ctlz.i129(i129 [[TMP55]], i1 true)
+; CHECK-NEXT: [[TMP61:%.*]] = trunc i129 [[TMP60]] to i32
+; CHECK-NEXT: [[TMP62:%.*]] = sub i32 129, [[TMP61]]
+; CHECK-NEXT: [[TMP63:%.*]] = sub i32 128, [[TMP61]]
+; CHECK-NEXT: [[TMP64:%.*]] = icmp sgt i32 [[TMP62]], 24
+; CHECK-NEXT: br i1 [[TMP64]], label [[ITOFP_IF_THEN4:%.*]], label [[ITOFP_IF_ELSE:%.*]]
+; CHECK: itofp-if-then4:
+; CHECK-NEXT: switch i32 [[TMP62]], label [[ITOFP_SW_DEFAULT:%.*]] [
+; CHECK-NEXT: i32 25, label [[ITOFP_SW_BB:%.*]]
+; CHECK-NEXT: i32 26, label [[ITOFP_SW_EPILOG:%.*]]
+; CHECK-NEXT: ]
+; CHECK: itofp-sw-bb:
+; CHECK-NEXT: [[TMP65:%.*]] = shl i129 [[TMP55]], 1
+; CHECK-NEXT: br label [[ITOFP_SW_EPILOG]]
+; CHECK: itofp-sw-default:
+; CHECK-NEXT: [[TMP66:%.*]] = sub i32 103, [[TMP61]]
+; CHECK-NEXT: [[TMP67:%.*]] = zext i32 [[TMP66]] to i129
+; CHECK-NEXT: [[TMP68:%.*]] = lshr i129 [[TMP55]], [[TMP67]]
+; CHECK-NEXT: [[TMP69:%.*]] = add i32 [[TMP61]], 26
+; CHECK-NEXT: [[TMP70:%.*]] = zext i32 [[TMP69]] to i129
+; CHECK-NEXT: [[TMP71:%.*]] = lshr i129 -1, [[TMP70]]
+; CHECK-NEXT: [[TMP72:%.*]] = and i129 [[TMP71]], [[TMP55]]
+; CHECK-NEXT: [[TMP73:%.*]] = icmp ne i129 [[TMP72]], 0
+; CHECK-NEXT: [[TMP74:%.*]] = zext i1 [[TMP73]] to i129
+; CHECK-NEXT: [[TMP75:%.*]] = or i129 [[TMP68]], [[TMP74]]
+; CHECK-NEXT: br label [[ITOFP_SW_EPILOG]]
+; CHECK: itofp-sw-epilog:
+; CHECK-NEXT: [[TMP76:%.*]] = phi i129 [ [[TMP75]], [[ITOFP_SW_DEFAULT]] ], [ [[TMP55]], [[ITOFP_IF_THEN4]] ], [ [[TMP65]], [[ITOFP_SW_BB]] ]
+; CHECK-NEXT: [[TMP77:%.*]] = trunc i129 [[TMP76]] to i32
+; CHECK-NEXT: [[TMP78:%.*]] = lshr i32 [[TMP77]], 2
+; CHECK-NEXT: [[TMP79:%.*]] = and i32 [[TMP78]], 1
+; CHECK-NEXT: [[TMP80:%.*]] = zext i32 [[TMP79]] to i129
+; CHECK-NEXT: [[TMP81:%.*]] = or i129 [[TMP76]], [[TMP80]]
+; CHECK-NEXT: [[TMP82:%.*]] = add i129 [[TMP81]], 1
+; CHECK-NEXT: [[TMP83:%.*]] = lshr i129 [[TMP82]], 2
+; CHECK-NEXT: [[A3:%.*]] = and i129 [[TMP82]], 67108864
+; CHECK-NEXT: [[TMP84:%.*]] = icmp eq i129 [[A3]], 0
+; CHECK-NEXT: [[TMP85:%.*]] = trunc i129 [[TMP83]] to i32
+; CHECK-NEXT: [[TMP86:%.*]] = lshr i129 [[TMP83]], 32
+; CHECK-NEXT: [[TMP87:%.*]] = trunc i129 [[TMP86]] to i32
+; CHECK-NEXT: br i1 [[TMP84]], label [[ITOFP_IF_END26:%.*]], label [[ITOFP_IF_THEN20:%.*]]
+; CHECK: itofp-if-then20:
+; CHECK-NEXT: [[TMP88:%.*]] = lshr i129 [[TMP82]], 3
+; CHECK-NEXT: [[TMP89:%.*]] = trunc i129 [[TMP88]] to i32
+; CHECK-NEXT: [[TMP90:%.*]] = lshr i129 [[TMP88]], 32
+; CHECK-NEXT: [[TMP91:%.*]] = trunc i129 [[TMP90]] to i32
+; CHECK-NEXT: br label [[ITOFP_IF_END26]]
+; CHECK: itofp-if-else:
+; CHECK-NEXT: [[TMP92:%.*]] = add i32 [[TMP61]], -105
+; CHECK-NEXT: [[TMP93:%.*]] = zext i32 [[TMP92]] to i129
+; CHECK-NEXT: [[TMP94:%.*]] = shl i129 [[TMP55]], [[TMP93]]
+; CHECK-NEXT: [[TMP95:%.*]] = trunc i129 [[TMP94]] to i32
+; CHECK-NEXT: [[TMP96:%.*]] = lshr i129 [[TMP94]], 32
+; CHECK-NEXT: [[TMP97:%.*]] = trunc i129 [[TMP96]] to i32
+; CHECK-NEXT: br label [[ITOFP_IF_END26]]
+; CHECK: itofp-if-end26:
+; CHECK-NEXT: [[TMP98:%.*]] = phi i32 [ [[TMP89]], [[ITOFP_IF_THEN20]] ], [ [[TMP85]], [[ITOFP_SW_EPILOG]] ], [ [[TMP95]], [[ITOFP_IF_ELSE]] ]
+; CHECK-NEXT: [[TMP99:%.*]] = phi i32 [ [[TMP62]], [[ITOFP_IF_THEN20]] ], [ [[TMP63]], [[ITOFP_SW_EPILOG]] ], [ [[TMP63]], [[ITOFP_IF_ELSE]] ]
+; CHECK-NEXT: [[TMP100:%.*]] = trunc i129 [[TMP57]] to i32
+; CHECK-NEXT: [[TMP101:%.*]] = and i32 [[TMP100]], -2147483648
+; CHECK-NEXT: [[TMP102:%.*]] = shl i32 [[TMP99]], 23
+; CHECK-NEXT: [[TMP103:%.*]] = add i32 [[TMP102]], 1065353216
+; CHECK-NEXT: [[TMP104:%.*]] = and i32 [[TMP98]], 8388607
+; CHECK-NEXT: [[TMP105:%.*]] = or i32 [[TMP104]], [[TMP101]]
+; CHECK-NEXT: [[TMP106:%.*]] = or i32 [[TMP104]], [[TMP103]]
+; CHECK-NEXT: [[TMP107:%.*]] = bitcast i32 [[TMP106]] to float
+; CHECK-NEXT: br label [[ITOFP_RETURN]]
+; CHECK: itofp-return:
+; CHECK-NEXT: [[TMP108:%.*]] = phi float [ [[TMP107]], [[ITOFP_IF_END26]] ], [ 0.000000e+00, [[ITOFP_RETURN1]] ]
+; CHECK-NEXT: [[TMP109:%.*]] = insertelement <2 x float> [[TMP54]], float [[TMP108]], i64 1
+; CHECK-NEXT: ret <2 x float> [[TMP109]]
+;
+ %conv = uitofp <2 x i129> %a to <2 x float>
+ ret <2 x float> %conv
+}
More information about the llvm-commits
mailing list