Skip to content

Conversation

@AZero13
Copy link
Contributor

@AZero13 AZero13 commented Jul 31, 2025

This also means we don't need a jump table very time we find the opposite condition.

@llvmbot
Copy link
Member

llvmbot commented Jul 31, 2025

@llvm/pr-subscribers-backend-arm

Author: AZero13 (AZero13)

Changes

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 --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

@AZero13 AZero13 closed this Aug 1, 2025
@AZero13 AZero13 deleted the patch-3 branch August 1, 2025 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants