[PATCH] D154821: [FuncSpec] Prefer DataLayout-aware constant folding of GEPs.
Alexandros Lamprineas via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 11 05:48:16 PDT 2023
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1d0476cb4d15: [FuncSpec] Prefer DataLayout-aware constant folding of GEPs. (authored by labrinea).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D154821/new/
https://reviews.llvm.org/D154821
Files:
llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
llvm/unittests/Transforms/IPO/FunctionSpecializationTest.cpp
Index: llvm/unittests/Transforms/IPO/FunctionSpecializationTest.cpp
===================================================================
--- llvm/unittests/Transforms/IPO/FunctionSpecializationTest.cpp
+++ llvm/unittests/Transforms/IPO/FunctionSpecializationTest.cpp
@@ -281,8 +281,8 @@
Ref = getInstCost(Gep) + getInstCost(Load) + getInstCost(Freeze) +
getInstCost(Smax);
Bonus = Specializer.getSpecializationBonus(F->getArg(2), GV, Visitor);
- EXPECT_NE(Bonus, Ref);
- EXPECT_FALSE(Bonus > 0);
+ EXPECT_EQ(Bonus, Ref);
+ EXPECT_TRUE(Bonus > 0);
Bonus = Specializer.getSpecializationBonus(F->getArg(3), Undef, Visitor);
EXPECT_TRUE(Bonus == 0);
Index: llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
===================================================================
--- llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
+++ llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
@@ -55,7 +55,6 @@
#include "llvm/Analysis/ValueLattice.h"
#include "llvm/Analysis/ValueLatticeUtils.h"
#include "llvm/Analysis/ValueTracking.h"
-#include "llvm/IR/ConstantFold.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/Transforms/Scalar/SCCP.h"
#include "llvm/Transforms/Utils/Cloning.h"
@@ -260,7 +259,7 @@
}
Constant *InstCostVisitor::visitGetElementPtrInst(GetElementPtrInst &I) {
- SmallVector<Value *, 8> Operands;
+ SmallVector<Constant *, 8> Operands;
Operands.reserve(I.getNumOperands());
for (unsigned Idx = 0, E = I.getNumOperands(); Idx != E; ++Idx) {
@@ -273,10 +272,8 @@
Operands.push_back(C);
}
- auto *Ptr = cast<Constant>(Operands[0]);
- auto Ops = ArrayRef(Operands.begin() + 1, Operands.end());
- return ConstantFoldGetElementPtr(I.getSourceElementType(), Ptr,
- I.isInBounds(), std::nullopt, Ops);
+ auto Ops = ArrayRef(Operands.begin(), Operands.end());
+ return ConstantFoldInstOperands(&I, Ops, DL);
}
Constant *InstCostVisitor::visitSelectInst(SelectInst &I) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D154821.539042.patch
Type: text/x-patch
Size: 1975 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230711/6ee10738/attachment.bin>
More information about the llvm-commits
mailing list