Skip to content

Conversation

@AZero13
Copy link
Contributor

@AZero13 AZero13 commented Aug 12, 2025

During comparison optimization, many subs become sub, which is good. However, this means that now there are new cse opportunities that can be exploited because now, NZCV is no longer a use in those instructions.

This will come into play more as I set ADDS to be the default rather than add for CSE purposes.

@llvmbot
Copy link
Member

llvmbot commented Aug 12, 2025

@llvm/pr-subscribers-backend-aarch64

Author: AZero13 (AZero13)

Changes

During comparison optimization, many subs become sub, which is good. However, this means that now there are new cse opportunities that can be exploited because now, NZCV is no longer a use in those instructions.

This will come into play more as I set ADDS to be the default rather than add for CSE purposes.


Full diff: https://github.com/llvm/llvm-project/pull/153316.diff

1 Files Affected:

  • (modified) llvm/lib/Target/AArch64/AArch64TargetMachine.cpp (+6)
diff --git a/llvm/lib/Target/AArch64/AArch64TargetMachine.cpp b/llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
index 95eab16511e5a..3e44d9efe7ed3 100644
--- a/llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
+++ b/llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
@@ -790,6 +790,12 @@ void AArch64PassConfig::addMachineSSAOptimization() {
 
   if (TM->getOptLevel() != CodeGenOptLevel::None)
     addPass(createAArch64MIPeepholeOptPass());
+
+  // Clean-up any last code that can be eliminated
+  // Due to the fact that the demotion of some instructions
+  // can result in the removal of instructions previously unable to be removed
+  addPass(&MachineCSELegacyID);
+  addPass(&DeadMachineInstructionElimID);
 }
 
 bool AArch64PassConfig::addILPOpts() {

During comparison optimization, many subs become sub, which is good. However, this means that now there are new cse opportunities that can be exploited because now, NZCV is no longer a use in those instructions.

This will come into play more as I set ADDS to be the default rather than add for CSE purposes.
@AZero13 AZero13 changed the title [AArch64] Run CSE one last time [AArch64] Run CSE after conversion from flag-setting variants to non-flag setting variants Aug 13, 2025
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