Skip to content

Conversation

@guy-david
Copy link
Contributor

@guy-david guy-david commented Nov 22, 2025

Otherwise, the register allocator may spill and reload constants that can be rematerialized with a single instruction.
We have the same behaviour for movi.2d, but this change concerns floating-point instructions such as fmov.4s v0, #1.00000000 or fmov.2d v0, #0.25000000.

@llvmbot
Copy link
Member

llvmbot commented Nov 22, 2025

@llvm/pr-subscribers-backend-aarch64

Author: Guy David (guy-david)

Changes

Otherwise, the register allocator may spill and reload constants that can be rematerialized with a single instruction.
This concerns instructions such as fmov.4s v0, #<!-- -->1.00000000 or fmov.2d v0, #<!-- -->0.25000000.


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

1 Files Affected:

  • (modified) llvm/lib/Target/AArch64/AArch64InstrInfo.td (+2)
diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.td b/llvm/lib/Target/AArch64/AArch64InstrInfo.td
index 50a3a4ab8d8b6..8dca6a054aa52 100644
--- a/llvm/lib/Target/AArch64/AArch64InstrInfo.td
+++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.td
@@ -8354,6 +8354,7 @@ def : InstAlias<"orr.4s $Vd, $imm", (ORRv4i32 V128:$Vd, imm0_255:$imm, 0)>;
 }
 
 // AdvSIMD FMOV
+let isReMaterializable = 1, isAsCheapAsAMove = 1 in {
 def FMOVv2f64_ns : SIMDModifiedImmVectorNoShift<1, 1, 0, 0b1111, V128, fpimm8,
                                               "fmov", ".2d",
                        [(set (v2f64 V128:$Rd), (AArch64fmov imm0_255:$imm8))]>;
@@ -8371,6 +8372,7 @@ def FMOVv8f16_ns : SIMDModifiedImmVectorNoShift<1, 0, 1, 0b1111, V128, fpimm8,
                                               "fmov", ".8h",
                        [(set (v8f16 V128:$Rd), (AArch64fmov imm0_255:$imm8))]>;
 } // Predicates = [HasNEON, HasFullFP16]
+}
 
 // AdvSIMD MOVI
 

Copy link
Contributor

@tomershafir tomershafir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pls add a test for all of the variants that verifies they get rematerialized

@guy-david guy-david force-pushed the users/guy-david/aarch64-fmov-vec-imm-rematerializable branch from bac88b5 to 592ce32 Compare November 23, 2025 16:03
@github-actions
Copy link

github-actions bot commented Nov 23, 2025

✅ With the latest revision this PR passed the undef deprecator.

@guy-david guy-david force-pushed the users/guy-david/aarch64-fmov-vec-imm-rematerializable branch 2 times, most recently from 9132a1b to eea688f Compare November 23, 2025 16:13
@guy-david guy-david force-pushed the users/guy-david/aarch64-fmov-vec-imm-rematerializable branch from eea688f to b5750aa Compare November 23, 2025 17:02
Otherwise, the register allocator may spill and reload constants that
can be rematerialized with a single instruction.
@guy-david guy-david force-pushed the users/guy-david/aarch64-fmov-vec-imm-rematerializable branch from b5750aa to 9be344a Compare November 23, 2025 17:24
Copy link
Collaborator

@davemgreen davemgreen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks - LGTM

@guy-david guy-david merged commit 6a395fe into main Nov 25, 2025
10 checks passed
@guy-david guy-david deleted the users/guy-david/aarch64-fmov-vec-imm-rematerializable branch November 25, 2025 16:29
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.

5 participants