aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@sifive.com>2021-08-19 07:18:30 -0700
committerCraig Topper <craig.topper@sifive.com>2021-08-19 07:18:33 -0700
commitadd08c874147638e52d89eb07e40797dbc98d73b (patch)
tree3ad47126510d80eb507f3a2bb8ec62ae13ae9862 /llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
parentc60a4c1ba5980754f78765120c1ae88e1fe3cb32 (diff)
downloadllvm-add08c874147638e52d89eb07e40797dbc98d73b.zip
llvm-add08c874147638e52d89eb07e40797dbc98d73b.tar.gz
llvm-add08c874147638e52d89eb07e40797dbc98d73b.tar.bz2
[SelectionDAGBuilder] Compute and cache PreferredExtendType on demand.
Previously we pre-calculated this and cached it for every instruction in the function. Most of the calculated results will never be used. So instead calculate it only on the first use, and then cache it. The cache was originally added to fix a compile time issue which caused r216066 to be reverted. This change exposed that we weren't pre-computing the Value for Arguments. I've explicitly disabled that for now as it seemed to regress some tests on AArch64 which has sext built into its compare instructions. Spotted while investigating how to improve heuristics to work better with RISCV preferring sign extend for unsigned compares for i32 on RV64. Reviewed By: RKSimon Differential Revision: https://reviews.llvm.org/D107976
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp25
1 files changed, 0 insertions, 25 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp b/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
index 85c6eca..6a08304 100644
--- a/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
@@ -57,28 +57,6 @@ static bool isUsedOutsideOfDefiningBlock(const Instruction *I) {
return false;
}
-static ISD::NodeType getPreferredExtendForValue(const Value *V) {
- // For the users of the source value being used for compare instruction, if
- // the number of signed predicate is greater than unsigned predicate, we
- // prefer to use SIGN_EXTEND.
- //
- // With this optimization, we would be able to reduce some redundant sign or
- // zero extension instruction, and eventually more machine CSE opportunities
- // can be exposed.
- ISD::NodeType ExtendKind = ISD::ANY_EXTEND;
- unsigned NumOfSigned = 0, NumOfUnsigned = 0;
- for (const User *U : V->users()) {
- if (const auto *CI = dyn_cast<CmpInst>(U)) {
- NumOfSigned += CI->isSigned();
- NumOfUnsigned += CI->isUnsigned();
- }
- }
- if (NumOfSigned > NumOfUnsigned)
- ExtendKind = ISD::SIGN_EXTEND;
-
- return ExtendKind;
-}
-
void FunctionLoweringInfo::set(const Function &fn, MachineFunction &mf,
SelectionDAG *DAG) {
Fn = &fn;
@@ -233,9 +211,6 @@ void FunctionLoweringInfo::set(const Function &fn, MachineFunction &mf,
if (isUsedOutsideOfDefiningBlock(&I))
if (!isa<AllocaInst>(I) || !StaticAllocaMap.count(cast<AllocaInst>(&I)))
InitializeRegForValue(&I);
-
- // Decide the preferred extend type for a value.
- PreferredExtendType[&I] = getPreferredExtendForValue(&I);
}
}