[PATCH] D131489: [TypePromotion] Hoist out Promote Width calculation
Andre Vieira via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 11 01:50:46 PDT 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rG05fc5037cd6c: [TypePromotion] Hoist out Promote Width calculation (authored by avieira).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D131489/new/
https://reviews.llvm.org/D131489
Files:
llvm/lib/CodeGen/TypePromotion.cpp
Index: llvm/lib/CodeGen/TypePromotion.cpp
===================================================================
--- llvm/lib/CodeGen/TypePromotion.cpp
+++ llvm/lib/CodeGen/TypePromotion.cpp
@@ -905,6 +905,30 @@
TII.getRegisterBitWidth(TargetTransformInfo::RGK_Scalar).getFixedSize();
Ctx = &F.getParent()->getContext();
+ // Return the preferred integer width of the instruction, or zero if we
+ // shouldn't try.
+ auto GetPromoteWidth = [&](Instruction *I) -> uint32_t {
+ if (!isa<IntegerType>(I->getType()))
+ return 0;
+
+ EVT SrcVT = TLI->getValueType(DL, I->getType());
+ if (SrcVT.isSimple() && TLI->isTypeLegal(SrcVT.getSimpleVT()))
+ return 0;
+
+ if (TLI->getTypeAction(*Ctx, SrcVT) != TargetLowering::TypePromoteInteger)
+ return 0;
+
+ EVT PromotedVT = TLI->getTypeToTransformTo(*Ctx, SrcVT);
+ if (RegisterBitWidth < PromotedVT.getFixedSizeInBits()) {
+ LLVM_DEBUG(dbgs() << "IR Promotion: Couldn't find target register "
+ << "for promoted type\n");
+ return 0;
+ }
+
+ // TODO: Should we prefer to use RegisterBitWidth instead?
+ return PromotedVT.getFixedSizeInBits();
+ };
+
// Search up from icmps to try to promote their operands.
for (BasicBlock &BB : F) {
for (Instruction &I : BB) {
@@ -915,30 +939,19 @@
continue;
auto *ICmp = cast<ICmpInst>(&I);
- // Skip signed or pointer compares
- if (ICmp->isSigned() || !isa<IntegerType>(ICmp->getOperand(0)->getType()))
+
+ // Skip signed
+ if (ICmp->isSigned())
continue;
LLVM_DEBUG(dbgs() << "IR Promotion: Searching from: " << *ICmp << "\n");
for (auto &Op : ICmp->operands()) {
- if (auto *I = dyn_cast<Instruction>(Op)) {
- EVT SrcVT = TLI->getValueType(DL, I->getType());
- if (SrcVT.isSimple() && TLI->isTypeLegal(SrcVT.getSimpleVT()))
- break;
-
- if (TLI->getTypeAction(*Ctx, SrcVT) !=
- TargetLowering::TypePromoteInteger)
- break;
- EVT PromotedVT = TLI->getTypeToTransformTo(*Ctx, SrcVT);
- if (RegisterBitWidth < PromotedVT.getFixedSizeInBits()) {
- LLVM_DEBUG(dbgs() << "IR Promotion: Couldn't find target register "
- << "for promoted type\n");
+ if (auto *OpI = dyn_cast<Instruction>(Op)) {
+ if (auto PromotedWidth = GetPromoteWidth(OpI)) {
+ MadeChange |= TryToPromote(OpI, PromotedWidth);
break;
}
-
- MadeChange |= TryToPromote(I, PromotedVT.getFixedSizeInBits());
- break;
}
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131489.451773.patch
Type: text/x-patch
Size: 2647 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220811/7cfad5fe/attachment.bin>
More information about the llvm-commits
mailing list