[llvm] r232967 - [AArch64] Enable rematerialization of float 0 values.

Chad Rosier mcrosier at codeaurora.org
Mon Mar 23 10:19:34 PDT 2015


Author: mcrosier
Date: Mon Mar 23 12:19:34 2015
New Revision: 232967

URL: http://llvm.org/viewvc/llvm-project?rev=232967&view=rev
Log:
[AArch64] Enable rematerialization of float 0 values.

Patch by Geoff Berry<gberry at codeaurora.org>.

Added:
    llvm/trunk/test/CodeGen/AArch64/remat-float0.ll
Modified:
    llvm/trunk/lib/Target/AArch64/AArch64InstrInfo.td

Modified: llvm/trunk/lib/Target/AArch64/AArch64InstrInfo.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AArch64InstrInfo.td?rev=232967&r1=232966&r2=232967&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AArch64/AArch64InstrInfo.td (original)
+++ llvm/trunk/lib/Target/AArch64/AArch64InstrInfo.td Mon Mar 23 12:19:34 2015
@@ -2348,8 +2348,15 @@ defm UCVTF : IntegerToFP<1, "ucvtf", uin
 
 defm FMOV : UnscaledConversion<"fmov">;
 
-def : Pat<(f32 (fpimm0)), (FMOVWSr WZR)>, Requires<[NoZCZ]>;
-def : Pat<(f64 (fpimm0)), (FMOVXDr XZR)>, Requires<[NoZCZ]>;
+// Add pseudo ops for FMOV 0 so we can mark them as isReMaterializable
+let isReMaterializable = 1, isCodeGenOnly = 1 in {
+def FMOVS0 : Pseudo<(outs FPR32:$Rd), (ins), [(set f32:$Rd, (fpimm0))]>,
+    PseudoInstExpansion<(FMOVWSr FPR32:$Rd, WZR)>,
+    Requires<[NoZCZ]>;
+def FMOVD0 : Pseudo<(outs FPR64:$Rd), (ins), [(set f64:$Rd, (fpimm0))]>,
+    PseudoInstExpansion<(FMOVXDr FPR64:$Rd, XZR)>,
+    Requires<[NoZCZ]>;
+}
 
 //===----------------------------------------------------------------------===//
 // Floating point conversion instruction.

Added: llvm/trunk/test/CodeGen/AArch64/remat-float0.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AArch64/remat-float0.ll?rev=232967&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/AArch64/remat-float0.ll (added)
+++ llvm/trunk/test/CodeGen/AArch64/remat-float0.ll Mon Mar 23 12:19:34 2015
@@ -0,0 +1,18 @@
+; RUN: llc < %s -mtriple=aarch64-none-linux-gnu -verify-machineinstrs
+
+; Check that float 0 gets rematerialized with an fmov of zero reg instead
+; of spilled/filled.
+
+declare void @bar(float)
+
+define void @foo() {
+; CHECK-LABEL: foo:
+; CHECK: fmov s0, wzr
+; CHECK: bl bar
+; CHECK: fmov s0, wzr
+; CHECK: bl bar
+  call void @bar(float 0.000000e+00)
+  call void asm sideeffect "", "~{s0},~{s1},~{s2},~{s3},~{s4},~{s5},~{s6},~{s7},~{s8},~{s9},~{s10},~{s11},~{s12},~{s13},~{s14},~{s15},~{s16},~{s17},~{s18},~{s19},~{s20},~{s21},~{s22},~{s23},~{s24},~{s25},~{s26},~{s27},~{s28},~{s29},~{s30},~{s31}"()
+  call void @bar(float 0.000000e+00)
+  ret void
+}





More information about the llvm-commits mailing list