Skip to content

Commit fe03841

Browse files
committed
Peek through freeze to see XOR
1 parent a8280c4 commit fe03841

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10016,8 +10016,15 @@ SDValue DAGCombiner::visitXOR(SDNode *N) {
1001610016
}
1001710017
}
1001810018

10019+
auto PeekThroughFreeze = [](SDValue N) {
10020+
if (N->getOpcode() == ISD::FREEZE && N.hasOneUse())
10021+
return N->getOperand(0);
10022+
return N;
10023+
};
10024+
1001910025
// fold (xor x, x) -> 0
10020-
if (N0 == N1)
10026+
// FIXME: Refactor this and sub and other similar operations together.
10027+
if (PeekThroughFreeze(N0) == PeekThroughFreeze(N1))
1002110028
return tryFoldToZero(DL, TLI, VT, DAG, LegalOperations);
1002210029

1002310030
// fold (xor (shl 1, x), -1) -> (rotl ~1, x)

0 commit comments

Comments
 (0)