[llvm] [NFC][AArch64] ConditionOptimizer: replace hardcoded CC switch with TII hook (PR #188389)
Nashe Mncube via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 25 06:27:26 PDT 2026
================
@@ -375,20 +376,9 @@ void AArch64ConditionOptimizerImpl::updateCmpInstr(MachineInstr *CmpMI,
// Modifies the condition code of a conditional instruction.
void AArch64ConditionOptimizerImpl::updateCondInstr(MachineInstr *CondMI,
AArch64CC::CondCode NewCC) {
- // Get the correct operand index for the conditional instruction
- unsigned CondOpIdx;
- switch (CondMI->getOpcode()) {
- case AArch64::Bcc:
- CondOpIdx = 0;
- break;
- case AArch64::CSINCWr:
- case AArch64::CSINCXr:
- CondOpIdx = 3;
- break;
- default:
- llvm_unreachable("Unsupported conditional instruction");
- }
- CondMI->getOperand(CondOpIdx).setImm(NewCC);
+ int CCOpIdx = TII->findCondCodeOpIdx(*CondMI);
----------------
nasherm wrote:
> we only need to change the other two calls to the function.
Yeah but one of the references to that function is not a static class member. Which means you're going to have to change another function's signature (and it's call sites) to permit this
> I feel it would be a better name and the more complete implementation wouldn't hurt. What are your thoughts?
I would like a more complete implementation but it doesn't seem like there's much use for it right now (plus it would break the NFC tag of this change). Longer function names aren't as much of a problem for me. If anything it helps with readability
https://github.com/llvm/llvm-project/pull/188389
More information about the llvm-commits
mailing list