[llvm] [AArch64] Have fallback for getSwappedCondition(CC) in the Fold check. (PR #160753)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 25 11:38:27 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-aarch64
Author: AZero13 (AZero13)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/160753.diff
1 Files Affected:
- (modified) llvm/lib/Target/AArch64/AArch64ISelLowering.cpp (+4-1)
``````````diff
diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
index a4c1e265f0e63..0e68d5b570c28 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -25764,8 +25764,11 @@ static SDValue reassociateCSELOperandsForCSE(SDNode *N, SelectionDAG &DAG) {
// Try again with the operands of the SUBS instruction and the condition
// swapped. Due to canonicalization, this only helps for non-constant
// operands of the SUBS instruction.
+ auto NewCC = getSwappedCondition(CC);
+ if (NewCC == AArch64CC::AL)
+ return SDValue();
std::swap(CmpOpToMatch, CmpOpOther);
- if (SDValue R = Fold(getSwappedCondition(CC), CmpOpToMatch, CmpOpToMatch))
+ if (SDValue R = Fold(NewCC, CmpOpToMatch, CmpOpToMatch))
return R;
return SDValue();
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/160753
More information about the llvm-commits
mailing list