Skip to content

Commit 64b2b58

Browse files
committed
[AArch64] Do not try to fold if getSwappedCondition(CC) has no swapped condition
NFC for now, but if we simplify nodes where we can remove a compare with 0 and we are stuck with condition codes MI or PL, we are in trouble, as you cannot swap that.
1 parent f87d6af commit 64b2b58

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25985,9 +25985,12 @@ static SDValue reassociateCSELOperandsForCSE(SDNode *N, SelectionDAG &DAG) {
2598525985
// Try again with the operands of the SUBS instruction and the condition
2598625986
// swapped. Due to canonicalization, this only helps for non-constant
2598725987
// operands of the SUBS instruction.
25988-
std::swap(CmpOpToMatch, CmpOpOther);
25989-
if (SDValue R = Fold(getSwappedCondition(CC), CmpOpToMatch, CmpOpToMatch))
25990-
return R;
25988+
auto NewCC = getSwappedCondition(CC);
25989+
if (NewCC != AArch64CC::AL) {
25990+
std::swap(CmpOpToMatch, CmpOpOther);
25991+
if (SDValue R = Fold(NewCC, CmpOpToMatch, CmpOpToMatch))
25992+
return R;
25993+
}
2599125994
return SDValue();
2599225995
}
2599325996

0 commit comments

Comments
 (0)