[llvm] [BOLT][AArch64] Support FEAT_CMPBR branch instructions. (PR #174972)
Alexandros Lamprineas via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 28 02:59:44 PST 2026
================
@@ -1844,8 +1844,21 @@ class AArch64MCPlusBuilder : public MCPlusBuilder {
}
}
+ bool isReversibleBranch(const MCInst &Inst) const override {
+ if (isCompAndBranch(Inst)) {
+ unsigned InvertedOpcode = getInvertedBranchOpcode(Inst.getOpcode());
+ if (needsImmDec(InvertedOpcode))
+ return Inst.getOperand(1).getImm() > 0;
+ if (needsImmInc(InvertedOpcode))
+ return Inst.getOperand(1).getImm() < 63;
+ }
+ return MCPlusBuilder::isReversibleBranch(Inst);
+ }
+
void reverseBranchCondition(MCInst &Inst, const MCSymbol *TBB,
MCContext *Ctx) const override {
+ assert(isReversibleBranch(Inst) && "Cannot reverse branch");
----------------
labrinea wrote:
I think it is too late to exit here. The caller of reverseBranchCondition relies on successful transformation therefore we must assert.
https://github.com/llvm/llvm-project/pull/174972
More information about the llvm-commits
mailing list