Skip to content

Commit 6fcb51f

Browse files
committed
only changed modified lines of code
1 parent be724f2 commit 6fcb51f

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,12 +1268,12 @@ SDValue DAGCombiner::reassociateOpsCommutative(unsigned Opc, const SDLoc &DL,
12681268
if (Opc == ISD::AND && TLI.hasAndNot(N1)) {
12691269
// Look for pattern: AND(AND(XOR(Constant, a), b), NOT(c))
12701270
// Transform to: AND(XOR(Constant, a), AND(b, NOT(c)))
1271-
1271+
12721272
// Check if N1 is NOT(c) - i.e., XOR(c, -1)
1273-
if (N1.getOpcode() == ISD::XOR &&
1273+
if (N1.getOpcode() == ISD::XOR &&
12741274
DAG.isConstantIntBuildVectorOrConstantInt(N1.getOperand(1)) &&
12751275
isAllOnesConstant(N1.getOperand(1))) {
1276-
1276+
12771277
// Check if one operand of N0 is XOR(Constant, a)
12781278
SDValue XorOp, OtherOp;
12791279
if (N00.getOpcode() == ISD::XOR) {
@@ -1285,7 +1285,7 @@ SDValue DAGCombiner::reassociateOpsCommutative(unsigned Opc, const SDLoc &DL,
12851285
} else {
12861286
return SDValue();
12871287
}
1288-
1288+
12891289
// Check if XOR has a constant operand
12901290
if (DAG.isConstantIntBuildVectorOrConstantInt(XorOp.getOperand(0)) ||
12911291
DAG.isConstantIntBuildVectorOrConstantInt(XorOp.getOperand(1))) {
@@ -7557,38 +7557,40 @@ SDValue DAGCombiner::visitAND(SDNode *N) {
75577557
// This allows the andn operation to be done in parallel with the xor
75587558
if (TLI.hasAndNot(N1) || TLI.hasAndNot(N0)) {
75597559
SDValue InnerAndOp0, InnerAndOp1, NotArg;
7560-
7560+
75617561
// Match: AND(AND(Op0, Op1), NOT(NotArg))
75627562
// where NOT is represented as XOR with all-ones
75637563
// m_And automatically handles commutativity
7564-
if (sd_match(N, m_And(m_OneUse(m_And(m_Value(InnerAndOp0),
7564+
if (sd_match(N, m_And(m_OneUse(m_And(m_Value(InnerAndOp0),
75657565
m_Value(InnerAndOp1))),
75667566
m_Xor(m_Value(NotArg), m_AllOnes())))) {
7567-
7568-
// Determine which operand is XOR(Constant, X) where Constant is not all-ones
7567+
7568+
// Determine which operand is XOR(Constant, X) where Constant is not
7569+
// all-ones
75697570
SDValue XorOp, OtherOp;
75707571
APInt XorConst;
7571-
7572+
75727573
// Try first operand - m_Xor handles commutativity for XOR operands
75737574
if (sd_match(InnerAndOp0, m_Xor(m_ConstInt(XorConst), m_Value())) &&
75747575
!XorConst.isAllOnes()) {
75757576
XorOp = InnerAndOp0;
75767577
OtherOp = InnerAndOp1;
7577-
} else if (sd_match(InnerAndOp1, m_Xor(m_ConstInt(XorConst), m_Value())) &&
7578+
} else if (sd_match(InnerAndOp1,
7579+
m_Xor(m_ConstInt(XorConst), m_Value())) &&
75787580
!XorConst.isAllOnes()) {
75797581
XorOp = InnerAndOp1;
75807582
OtherOp = InnerAndOp0;
75817583
} else {
75827584
// Pattern doesn't match - no XOR(Constant, X) found
75837585
XorOp = SDValue();
75847586
}
7585-
7587+
75867588
// If we found the pattern, apply the transformation
75877589
// Prevent infinite loops by checking OtherOp is not also a NOT
75887590
if (XorOp && !sd_match(OtherOp, m_Xor(m_Value(), m_AllOnes()))) {
75897591
// Get the NOT node (either N0 or N1)
75907592
SDValue NotOp = sd_match(N0, m_Xor(m_Value(), m_AllOnes())) ? N0 : N1;
7591-
7593+
75927594
// Transform: AND(AND(XOR(Constant, a), b), NOT(c))
75937595
// To: AND(XOR(Constant, a), AND(b, NOT(c)))
75947596
SDValue NewAnd = DAG.getNode(ISD::AND, DL, VT, OtherOp, NotOp);

0 commit comments

Comments
 (0)