[llvm] [LLVM][DAGCombiner] Look through freeze when combining extensions of loads (PR #175022)

Sander de Smalen via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 9 04:14:22 PST 2026


================
@@ -14512,14 +14512,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/freeze when frozen.
+  if (!Load || !ISD::isNON_EXTLoad(Load) || !ISD::isUNINDEXEDLoad(Load) ||
+      (Frozen && (!Load->hasOneUse() || !N0->hasOneUse())))
----------------
sdesmalen-arm wrote:

This code is adding an extra constraint for a single use of the load; I can see why this code doesn't handle more than one uses of the result value of the load if one of the uses is a freeze (I would expect all uses of the load to be frozen), but I don't see why this function couldn't handle more than one use of the frozen result?

Additionally, you may want to distinguish between the use of the Chain and the use of the loaded _value_ from the Load, when you check for number of uses?

https://github.com/llvm/llvm-project/pull/175022


More information about the llvm-commits mailing list