Skip to content

Commit

Permalink
Revert "[AArch64] Lower extending sitofp using tbl (llvm#92528)"
Browse files Browse the repository at this point in the history
This reverts commit d1a4f0c.

There are reports about test failures with Eigen and JAX.
  • Loading branch information
momchil-velikov authored and AlexisPerry committed Jun 27, 2024
1 parent 8a617a5 commit e537ed5
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 313 deletions.
3 changes: 1 addition & 2 deletions llvm/lib/CodeGen/CodeGenPrepare.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8331,8 +8331,7 @@ bool CodeGenPrepare::optimizeInst(Instruction *I, ModifyDT &ModifiedDT) {
if (OptimizeNoopCopyExpression(CI, *TLI, *DL))
return true;

if ((isa<UIToFPInst>(I) || isa<SIToFPInst>(I) || isa<FPToUIInst>(I) ||
isa<TruncInst>(I)) &&
if ((isa<UIToFPInst>(I) || isa<FPToUIInst>(I) || isa<TruncInst>(I)) &&
TLI->optimizeExtendOrTruncateConversion(
I, LI->getLoopFor(I->getParent()), *TTI))
return true;
Expand Down
37 changes: 2 additions & 35 deletions llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15965,24 +15965,6 @@ static Value *createTblShuffleForZExt(IRBuilderBase &Builder, Value *Op,
return Result;
}

static Value *createTblShuffleForSExt(IRBuilderBase &Builder, Value *Op,
FixedVectorType *DstTy,
bool IsLittleEndian) {
auto *SrcTy = cast<FixedVectorType>(Op->getType());
auto SrcWidth = cast<IntegerType>(SrcTy->getElementType())->getBitWidth();
auto DstWidth = cast<IntegerType>(DstTy->getElementType())->getBitWidth();

SmallVector<int> Mask;
if (!createTblShuffleMask(SrcWidth, DstWidth, SrcTy->getNumElements(),
!IsLittleEndian, Mask))
return nullptr;

auto *FirstEltZero = Builder.CreateInsertElement(
PoisonValue::get(SrcTy), Builder.getInt8(0), uint64_t(0));

return Builder.CreateShuffleVector(Op, FirstEltZero, Mask);
}

static void createTblForTrunc(TruncInst *TI, bool IsLittleEndian) {
IRBuilder<> Builder(TI);
SmallVector<Value *> Parts;
Expand Down Expand Up @@ -16163,29 +16145,14 @@ bool AArch64TargetLowering::optimizeExtendOrTruncateConversion(
Value *ZExt = createTblShuffleForZExt(
Builder, I->getOperand(0), FixedVectorType::getInteger(DstTy),
FixedVectorType::getInteger(DstTy), Subtarget->isLittleEndian());
assert(ZExt && "Cannot fail for the i8 to float conversion");
if (!ZExt)
return false;
auto *UI = Builder.CreateUIToFP(ZExt, DstTy);
I->replaceAllUsesWith(UI);
I->eraseFromParent();
return true;
}

auto *SIToFP = dyn_cast<SIToFPInst>(I);
if (SIToFP && SrcTy->getElementType()->isIntegerTy(8) &&
DstTy->getElementType()->isFloatTy()) {
IRBuilder<> Builder(I);
auto *Shuffle = createTblShuffleForSExt(Builder, I->getOperand(0),
FixedVectorType::getInteger(DstTy),
Subtarget->isLittleEndian());
assert(Shuffle && "Cannot fail for the i8 to float conversion");
auto *Cast = Builder.CreateBitCast(Shuffle, VectorType::getInteger(DstTy));
auto *AShr = Builder.CreateAShr(Cast, 24, "", true);
auto *SI = Builder.CreateSIToFP(AShr, DstTy);
I->replaceAllUsesWith(SI);
I->eraseFromParent();
return true;
}

// Convert 'fptoui <(8|16) x float> to <(8|16) x i8>' to a wide fptoui
// followed by a truncate lowered to using tbl.4.
auto *FPToUI = dyn_cast<FPToUIInst>(I);
Expand Down
276 changes: 0 additions & 276 deletions llvm/test/CodeGen/AArch64/sitofp-to-tbl.ll

This file was deleted.

0 comments on commit e537ed5

Please sign in to comment.