[llvm] [ARM] getOppositeCondition should match AArch64 (NFC) (PR #151550)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 31 09:10:47 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-arm
Author: AZero13 (AZero13)
<details>
<summary>Changes</summary>
This also means we don't need a jump table very time we find the opposite condition.
---
Full diff: https://github.com/llvm/llvm-project/pull/151550.diff
1 Files Affected:
- (modified) llvm/lib/Target/ARM/Utils/ARMBaseInfo.h (+3-17)
``````````diff
diff --git a/llvm/lib/Target/ARM/Utils/ARMBaseInfo.h b/llvm/lib/Target/ARM/Utils/ARMBaseInfo.h
index dc4f811e075c6..ebf4eaa122481 100644
--- a/llvm/lib/Target/ARM/Utils/ARMBaseInfo.h
+++ b/llvm/lib/Target/ARM/Utils/ARMBaseInfo.h
@@ -46,23 +46,9 @@ enum CondCodes { // Meaning (integer) Meaning (floating-point)
};
inline static CondCodes getOppositeCondition(CondCodes CC) {
- switch (CC) {
- default: llvm_unreachable("Unknown condition code");
- case EQ: return NE;
- case NE: return EQ;
- case HS: return LO;
- case LO: return HS;
- case MI: return PL;
- case PL: return MI;
- case VS: return VC;
- case VC: return VS;
- case HI: return LS;
- case LS: return HI;
- case GE: return LT;
- case LT: return GE;
- case GT: return LE;
- case LE: return GT;
- }
+ // To reverse a condition it's necessary to only invert the low bit:
+
+ return static_cast<CondCodes>(static_cast<unsigned>(CC) ^ 0x1);
}
/// getSwappedCondition - assume the flags are set by MI(a,b), return
``````````
</details>
https://github.com/llvm/llvm-project/pull/151550
More information about the llvm-commits
mailing list