[llvm] [DAGCombine] Fold icmp with chain of or of loads (PR #139165)

David Green via llvm-commits llvm-commits at lists.llvm.org
Fri May 9 03:41:17 PDT 2025


================
@@ -28654,7 +28738,15 @@ SDValue DAGCombiner::SimplifySetCC(EVT VT, SDValue N0, SDValue N1,
                                    bool foldBooleans) {
   TargetLowering::DAGCombinerInfo
     DagCombineInfo(DAG, Level, false, this);
-  return TLI.SimplifySetCC(VT, N0, N1, Cond, foldBooleans, DagCombineInfo, DL);
+  if (SDValue C =
+          TLI.SimplifySetCC(VT, N0, N1, Cond, foldBooleans, DagCombineInfo, DL))
+    return C;
+
+  if ((Cond == ISD::SETNE || Cond == ISD::SETEQ) && isNullConstant(N1) &&
+      N0.getOpcode() == ISD::OR)
+    if (SDValue Load = MatchOrOfLoadToLargeLoad(N0, DAG, TLI))
----------------
davemgreen wrote:

I don't believe so - we are still generating the setcc, only optimizing the loads into it. The compare is essentially checking if any bits of the input are set, and the compare should still generate the same result. This is the reverse of #137875 where the operands are a tree of loads.

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


More information about the llvm-commits mailing list