[llvm] [CodeGen][SDAG] Skip preferred extend at O0 (PR #92643)
via llvm-commits
llvm-commits at lists.llvm.org
Sat May 18 02:45:18 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-selectiondag
Author: None (aengelke)
<details>
<summary>Changes</summary>
This should be a pure optimization to avoid redundant extensions, but iterating over all users is expensive, so don't do this at -O0.
Note: I'm unsure whether this is required for something at O0, but it appears to be fine.
---
Full diff: https://github.com/llvm/llvm-project/pull/92643.diff
2 Files Affected:
- (modified) llvm/include/llvm/CodeGen/SelectionDAG.h (+1)
- (modified) llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp (+4-2)
``````````diff
diff --git a/llvm/include/llvm/CodeGen/SelectionDAG.h b/llvm/include/llvm/CodeGen/SelectionDAG.h
index 979ef8033eb5e..ed6962685f7b0 100644
--- a/llvm/include/llvm/CodeGen/SelectionDAG.h
+++ b/llvm/include/llvm/CodeGen/SelectionDAG.h
@@ -469,6 +469,7 @@ class SelectionDAG {
MachineFunction &getMachineFunction() const { return *MF; }
const Pass *getPass() const { return SDAGISelPass; }
+ CodeGenOptLevel getOptLevel() const { return OptLevel; }
const DataLayout &getDataLayout() const { return MF->getDataLayout(); }
const TargetMachine &getTarget() const { return TM; }
const TargetSubtargetInfo &getSubtarget() const { return MF->getSubtarget(); }
diff --git a/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp b/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
index 8fb6b11b8805c..35f840201e4ba 100644
--- a/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
@@ -222,8 +222,10 @@ void FunctionLoweringInfo::set(const Function &fn, MachineFunction &mf,
if (!isa<AllocaInst>(I) || !StaticAllocaMap.count(cast<AllocaInst>(&I)))
InitializeRegForValue(&I);
- // Decide the preferred extend type for a value.
- PreferredExtendType[&I] = getPreferredExtendForValue(&I);
+ // Decide the preferred extend type for a value. This iterates over all
+ // users and therefore isn't cheap, so don't do this at O0.
+ if (DAG->getOptLevel() != CodeGenOptLevel::None)
+ PreferredExtendType[&I] = getPreferredExtendForValue(&I);
}
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/92643
More information about the llvm-commits
mailing list