[PATCH] D120452: [AArch64] Use simd mov to materialize big fp constants

Dave Green via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 2 03:07:02 PST 2022


dmgreen added a comment.

Thanks for the updates. There are other forms of MOVI that might also be useful for some fp immediates. The one we have here (shift an i8 by 24) I imagine is the most useful, but the others could be good in places too. The MOVN's too. I'm not sure what the best way to generalise this would be. As far as I can tell it needs lots of checks to the various isAdvSIMDModImmTypeXYZ methods wherever it is? This seems like a good beginning at least.



================
Comment at: llvm/lib/Target/AArch64/AArch64InstrFormats.td:1210
+
+def fpimm32Simd : FPImmLeaf<f32, [{
+      uint64_t Enc = Imm.bitcastToAPInt().getZExtValue();
----------------
It's likely worth calling this out as a "AdvSIMDModImmType4" constant somehow. Maybe call it fpimm32SIMDModImmType4? Same for the XForm.


================
Comment at: llvm/lib/Target/AArch64/AArch64InstrInfo.td:6146
+// Using the MOVI to materialize fp constants.
+def : Pat<(f32 fpimm32Simd:$in),
+          (EXTRACT_SUBREG (MOVIv2i32 (fpimm32SimdXForm f32:$in), (i32 24)),
----------------
It is quite uncommon to not have NEON, but can you add a predicate for it:
```
let Predicates = [HasNEON] in {
```
It might be worth adding a run line without neon (`-mattr=-neon`) for the new remat test case too, to show the difference.


================
Comment at: llvm/test/CodeGen/AArch64/remat-const-float-simd.ll:7
+
+; float foo(void) { return float(0x7fffffff); }
+define float @foo() {
----------------
0x7fffffff -> 2147483648, as the 0x7fffffff gets rounded.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D120452/new/

https://reviews.llvm.org/D120452



More information about the llvm-commits mailing list