[llvm] [LLVM][DAGCombiner] Look through freeze when combining extensions of loads (PR #175022)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 27 08:46:08 PST 2026
================
@@ -14530,14 +14530,18 @@ static SDValue tryToFoldExtOfLoad(SelectionDAG &DAG, DAGCombiner &Combiner,
ISD::LoadExtType ExtLoadType,
ISD::NodeType ExtOpc,
bool NonNegZExt = false) {
- if (!ISD::isNON_EXTLoad(N0.getNode()) || !ISD::isUNINDEXEDLoad(N0.getNode()))
+ bool Frozen = N0.getOpcode() == ISD::FREEZE;
+ auto *Load = dyn_cast<LoadSDNode>(Frozen ? N0.getOperand(0) : N0);
+ // TODO: Support multiple uses of the load when frozen.
+ if (!Load || !ISD::isNON_EXTLoad(Load) || !ISD::isUNINDEXEDLoad(Load) ||
+ (Frozen && !Load->hasNUsesOfValue(1, 0)))
return {};
// If this is zext nneg, see if it would make sense to treat it as a sext.
if (NonNegZExt) {
assert(ExtLoadType == ISD::ZEXTLOAD && ExtOpc == ISD::ZERO_EXTEND &&
"Unexpected load type or opcode");
- for (SDNode *User : N0->users()) {
+ for (SDNode *User : Load->users()) {
----------------
RKSimon wrote:
It'd have been easier to review this if the refactor to a consistent use of the LN0/Load had been pulled out into a NFC pre-commit.
https://github.com/llvm/llvm-project/pull/175022
More information about the llvm-commits
mailing list