Skip to content

Conversation

@AZero13
Copy link
Contributor

@AZero13 AZero13 commented Jul 10, 2025

Now that SelectionDAG already peeks through freezes, this is not needed anymore.

Now that SelectionDAG already peeks through freezes, this is not needed anymore.
@llvmbot llvmbot added the llvm:SelectionDAG SelectionDAGISel as well label Jul 10, 2025
@llvmbot
Copy link
Member

llvmbot commented Jul 10, 2025

@llvm/pr-subscribers-llvm-selectiondag

Author: AZero13 (AZero13)

Changes

Now that SelectionDAG already peeks through freezes, this is not needed anymore.


Full diff: https://github.com/llvm/llvm-project/pull/148022.diff

1 Files Affected:

  • (modified) llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (+1-7)
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 9ffdda28f7899..6767606f0719a 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -4067,18 +4067,12 @@ SDValue DAGCombiner::visitSUB(SDNode *N) {
   unsigned BitWidth = VT.getScalarSizeInBits();
   SDLoc DL(N);
 
-  auto PeekThroughFreeze = [](SDValue N) {
-    if (N->getOpcode() == ISD::FREEZE && N.hasOneUse())
-      return N->getOperand(0);
-    return N;
-  };
-
   if (SDValue V = foldSubCtlzNot<EmptyMatchContext>(N, DAG))
     return V;
 
   // fold (sub x, x) -> 0
   // FIXME: Refactor this and xor and other similar operations together.
-  if (PeekThroughFreeze(N0) == PeekThroughFreeze(N1))
+  if (N0 == N1)
     return tryFoldToZero(DL, TLI, VT, DAG, LegalOperations);
 
   // fold (sub c1, c2) -> c3

@topperc
Copy link
Collaborator

topperc commented Jul 10, 2025

Here are two tests where I believe this code triggers https://godbolt.org/z/sY79E6d5o https://godbolt.org/z/raosvoWsT

@topperc topperc requested review from RKSimon and nikic July 10, 2025 23:05
@AZero13
Copy link
Contributor Author

AZero13 commented Jul 11, 2025

Here are two tests where I believe this code triggers https://godbolt.org/z/sY79E6d5o https://godbolt.org/z/raosvoWsT

you know i swapped sub with xor and suddenly the div made it

@AZero13
Copy link
Contributor Author

AZero13 commented Jul 11, 2025

Disregard this. Let's go back to #147821

@AZero13 AZero13 closed this Jul 11, 2025
@AZero13 AZero13 deleted the patch-3 branch July 11, 2025 01:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

llvm:SelectionDAG SelectionDAGISel as well

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants