]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
i386.c (ix86_rtx_costs): Enable fma for TARGET_AVX512F.
authorAlexander Ivchenko <alexander.ivchenko@intel.com>
Fri, 11 Oct 2013 14:00:11 +0000 (14:00 +0000)
committerKirill Yukhin <kyukhin@gcc.gnu.org>
Fri, 11 Oct 2013 14:00:11 +0000 (14:00 +0000)
        * config/i386/i386.c (ix86_rtx_costs): Enable fma for TARGET_AVX512F.
        * config/i386/sse.md (FMAMODEM): Changed modes and conditions.
        (FMAMODE): Ditto.
        (fma<mode>4): Removed condition.
        (fms<mode>4): Ditto.
        (fnma<mode>4): Ditto.
        (fnms<mode>4): Ditto.
        (fma4i_fmadd_<mode>): Ditto.
        (*fma_fmadd_<mode>): Ditto.
        (*fma_fmsub_<mode>): Ditto.
        (*fma_fnmadd_<mode>): Ditto.
        (*fma_fnmsub_<mode>): Ditto.
        (fmaddsub_<mode>): Allow for TARGET_AVX512F.
        (*fma_fmaddsub_<mode>): Ditto.
        (*fma_fmsubadd_<mode>): Ditto.
        (*fmai_fmadd_<mode>): Ditto.
        (*fmai_fmsub_<mode>): Ditto.
        (*fmai_fnmadd_<mode>): Ditto.
        (*fmai_fnmsub_<mode>): Ditto.

Co-Authored-By: Andrey Turetskiy <andrey.turetskiy@intel.com>
Co-Authored-By: Anna Tikhonova <anna.tikhonova@intel.com>
Co-Authored-By: Ilya Tocar <ilya.tocar@intel.com>
Co-Authored-By: Ilya Verbin <ilya.verbin@intel.com>
Co-Authored-By: Kirill Yukhin <kirill.yukhin@intel.com>
Co-Authored-By: Maxim Kuznetsov <maxim.kuznetsov@intel.com>
Co-Authored-By: Michael Zolotukhin <michael.v.zolotukhin@intel.com>
Co-Authored-By: Sergey Lega <sergey.s.lega@intel.com>
From-SVN: r203439

gcc/ChangeLog
gcc/config/i386/i386.c
gcc/config/i386/sse.md

index 7a694c064fc00b55a3da492893d2a191b8031a92..0fb3d0b714792608e40a3f1a221559e4be566369 100644 (file)
@@ -1,3 +1,33 @@
+2013-10-11  Alexander Ivchenko  <alexander.ivchenko@intel.com>
+           Maxim Kuznetsov  <maxim.kuznetsov@intel.com>
+           Sergey Lega  <sergey.s.lega@intel.com>
+           Anna Tikhonova  <anna.tikhonova@intel.com>
+           Ilya Tocar  <ilya.tocar@intel.com>
+           Andrey Turetskiy  <andrey.turetskiy@intel.com>
+           Ilya Verbin  <ilya.verbin@intel.com>
+           Kirill Yukhin  <kirill.yukhin@intel.com>
+           Michael Zolotukhin  <michael.v.zolotukhin@intel.com>
+
+       * config/i386/i386.c (ix86_rtx_costs): Enable fma for TARGET_AVX512F.
+       * config/i386/sse.md (FMAMODEM): Changed modes and conditions.
+       (FMAMODE): Ditto.
+       (fma<mode>4): Removed condition.
+       (fms<mode>4): Ditto.
+       (fnma<mode>4): Ditto.
+       (fnms<mode>4): Ditto.
+       (fma4i_fmadd_<mode>): Ditto.
+       (*fma_fmadd_<mode>): Ditto.
+       (*fma_fmsub_<mode>): Ditto.
+       (*fma_fnmadd_<mode>): Ditto.
+       (*fma_fnmsub_<mode>): Ditto.
+       (fmaddsub_<mode>): Allow for TARGET_AVX512F.
+       (*fma_fmaddsub_<mode>): Ditto.
+       (*fma_fmsubadd_<mode>): Ditto.
+       (*fmai_fmadd_<mode>): Ditto.
+       (*fmai_fmsub_<mode>): Ditto.
+       (*fmai_fnmadd_<mode>): Ditto.
+       (*fmai_fnmsub_<mode>): Ditto.
+
 2013-10-11  Alexander Ivchenko  <alexander.ivchenko@intel.com>
            Maxim Kuznetsov  <maxim.kuznetsov@intel.com>
            Sergey Lega  <sergey.s.lega@intel.com>
index 168a2ac50ead72320f4013de144318cfbe507512..37c1becbbd314d4113e3552cdd4ee87fcd556db8 100644 (file)
@@ -34811,7 +34811,7 @@ ix86_rtx_costs (rtx x, int code_i, int outer_code_i, int opno, int *total,
        rtx sub;
 
         gcc_assert (FLOAT_MODE_P (mode));
-        gcc_assert (TARGET_FMA || TARGET_FMA4);
+        gcc_assert (TARGET_FMA || TARGET_FMA4 || TARGET_AVX512F);
 
         /* ??? SSE scalar/vector cost should be used here.  */
         /* ??? Bald assumption that fma has the same cost as fmul.  */
index a3806906cc6329ba1eae493c1419717ee188d2c7..0b815217bed52019cb2de04a656a0f89a25f44ea 100644 (file)
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 ;; The standard names for scalar FMA are only available with SSE math enabled.
-(define_mode_iterator FMAMODEM [(SF "TARGET_SSE_MATH")
-                               (DF "TARGET_SSE_MATH")
-                               V4SF V2DF V8SF V4DF])
+;; CPUID bit AVX512F enables evex encoded scalar and 512-bit fma.  It doesn't
+;; care about FMA bit, so we enable fma for TARGET_AVX512F even when TARGET_FMA
+;; and TARGET_FMA4 are both false.
+;; TODO: In theory AVX512F does not automatically imply FMA, and without FMA
+;; one must force the EVEX encoding of the fma insns.  Ideally we'd improve
+;; GAS to allow proper prefix selection.  However, for the moment all hardware
+;; that supports AVX512F also supports FMA so we can ignore this for now.
+(define_mode_iterator FMAMODEM
+  [(SF "TARGET_SSE_MATH && (TARGET_FMA || TARGET_FMA4 || TARGET_AVX512F)")
+   (DF "TARGET_SSE_MATH && (TARGET_FMA || TARGET_FMA4 || TARGET_AVX512F)")
+   (V4SF "TARGET_FMA || TARGET_FMA4")
+   (V2DF "TARGET_FMA || TARGET_FMA4")
+   (V8SF "TARGET_FMA || TARGET_FMA4")
+   (V4DF "TARGET_FMA || TARGET_FMA4")
+   (V16SF "TARGET_AVX512F")
+   (V8DF "TARGET_AVX512F")])
 
 (define_expand "fma<mode>4"
   [(set (match_operand:FMAMODEM 0 "register_operand")
          (match_operand:FMAMODEM 1 "nonimmediate_operand")
          (match_operand:FMAMODEM 2 "nonimmediate_operand")
          (match_operand:FMAMODEM 3 "nonimmediate_operand")))]
-  "TARGET_FMA || TARGET_FMA4")
+  "")
 
 (define_expand "fms<mode>4"
   [(set (match_operand:FMAMODEM 0 "register_operand")
          (match_operand:FMAMODEM 1 "nonimmediate_operand")
          (match_operand:FMAMODEM 2 "nonimmediate_operand")
          (neg:FMAMODEM (match_operand:FMAMODEM 3 "nonimmediate_operand"))))]
-  "TARGET_FMA || TARGET_FMA4")
+  "")
 
 (define_expand "fnma<mode>4"
   [(set (match_operand:FMAMODEM 0 "register_operand")
          (neg:FMAMODEM (match_operand:FMAMODEM 1 "nonimmediate_operand"))
          (match_operand:FMAMODEM 2 "nonimmediate_operand")
          (match_operand:FMAMODEM 3 "nonimmediate_operand")))]
-  "TARGET_FMA || TARGET_FMA4")
+  "")
 
 (define_expand "fnms<mode>4"
   [(set (match_operand:FMAMODEM 0 "register_operand")
          (neg:FMAMODEM (match_operand:FMAMODEM 1 "nonimmediate_operand"))
          (match_operand:FMAMODEM 2 "nonimmediate_operand")
          (neg:FMAMODEM (match_operand:FMAMODEM 3 "nonimmediate_operand"))))]
-  "TARGET_FMA || TARGET_FMA4")
+  "")
 
 ;; The builtins for intrinsics are not constrained by SSE math enabled.
-(define_mode_iterator FMAMODE [SF DF V4SF V2DF V8SF V4DF])
+(define_mode_iterator FMAMODE [(SF "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512F")
+                              (DF "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512F")
+                              (V4SF "TARGET_FMA || TARGET_FMA4")
+                              (V2DF "TARGET_FMA || TARGET_FMA4")
+                              (V8SF "TARGET_FMA || TARGET_FMA4")
+                              (V4DF "TARGET_FMA || TARGET_FMA4")
+                              (V16SF "TARGET_AVX512F")
+                              (V8DF "TARGET_AVX512F")])
 
 (define_expand "fma4i_fmadd_<mode>"
   [(set (match_operand:FMAMODE 0 "register_operand")
          (match_operand:FMAMODE 1 "nonimmediate_operand")
          (match_operand:FMAMODE 2 "nonimmediate_operand")
          (match_operand:FMAMODE 3 "nonimmediate_operand")))]
-  "TARGET_FMA || TARGET_FMA4")
+  "")
 
 (define_insn "*fma_fmadd_<mode>"
   [(set (match_operand:FMAMODE 0 "register_operand" "=v,v,v,x,x")
          (match_operand:FMAMODE 1 "nonimmediate_operand" "%0, 0, v, x,x")
          (match_operand:FMAMODE 2 "nonimmediate_operand" "vm, v,vm, x,m")
          (match_operand:FMAMODE 3 "nonimmediate_operand" " v,vm, 0,xm,x")))]
-  "TARGET_FMA || TARGET_FMA4"
+  ""
   "@
    vfmadd132<ssemodesuffix>\t{%2, %3, %0|%0, %3, %2}
    vfmadd213<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
    (set_attr "type" "ssemuladd")
    (set_attr "mode" "<MODE>")])
 
-(define_insn "*fma_fmsub_<mode>"
+(define_insn "fma_fmsub_<mode>"
   [(set (match_operand:FMAMODE 0 "register_operand" "=v,v,v,x,x")
        (fma:FMAMODE
          (match_operand:FMAMODE   1 "nonimmediate_operand" "%0, 0, v, x,x")
          (match_operand:FMAMODE   2 "nonimmediate_operand" "vm, v,vm, x,m")
          (neg:FMAMODE
            (match_operand:FMAMODE 3 "nonimmediate_operand" " v,vm, 0,xm,x"))))]
-  "TARGET_FMA || TARGET_FMA4"
+  ""
   "@
    vfmsub132<ssemodesuffix>\t{%2, %3, %0|%0, %3, %2}
    vfmsub213<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
    (set_attr "type" "ssemuladd")
    (set_attr "mode" "<MODE>")])
 
-(define_insn "*fma_fnmadd_<mode>"
+(define_insn "fma_fnmadd_<mode>"
   [(set (match_operand:FMAMODE 0 "register_operand" "=v,v,v,x,x")
        (fma:FMAMODE
          (neg:FMAMODE
            (match_operand:FMAMODE 1 "nonimmediate_operand" "%0, 0, v, x,x"))
          (match_operand:FMAMODE   2 "nonimmediate_operand" "vm, v,vm, x,m")
          (match_operand:FMAMODE   3 "nonimmediate_operand" " v,vm, 0,xm,x")))]
-  "TARGET_FMA || TARGET_FMA4"
+  ""
   "@
    vfnmadd132<ssemodesuffix>\t{%2, %3, %0|%0, %3, %2}
    vfnmadd213<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
          (match_operand:FMAMODE   2 "nonimmediate_operand" "vm, v,vm, x,m")
          (neg:FMAMODE
            (match_operand:FMAMODE 3 "nonimmediate_operand" " v,vm, 0,xm,x"))))]
-  "TARGET_FMA || TARGET_FMA4"
+  ""
   "@
    vfnmsub132<ssemodesuffix>\t{%2, %3, %0|%0, %3, %2}
    vfnmsub213<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
           (match_operand:VF 2 "nonimmediate_operand")
           (match_operand:VF 3 "nonimmediate_operand")]
          UNSPEC_FMADDSUB))]
-  "TARGET_FMA || TARGET_FMA4")
+  "TARGET_FMA || TARGET_FMA4 || TARGET_AVX512F")
 
 (define_insn "*fma_fmaddsub_<mode>"
   [(set (match_operand:VF 0 "register_operand" "=v,v,v,x,x")
           (match_operand:VF 2 "nonimmediate_operand" "vm, v,vm, x,m")
           (match_operand:VF 3 "nonimmediate_operand" " v,vm, 0,xm,x")]
          UNSPEC_FMADDSUB))]
-  "TARGET_FMA || TARGET_FMA4"
+  "(TARGET_FMA || TARGET_FMA4 || TARGET_AVX512F)"
   "@
    vfmaddsub132<ssemodesuffix>\t{%2, %3, %0|%0, %3, %2}
    vfmaddsub213<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
           (neg:VF
             (match_operand:VF 3 "nonimmediate_operand" " v,vm, 0,xm,x"))]
          UNSPEC_FMADDSUB))]
-  "TARGET_FMA || TARGET_FMA4"
+  "(TARGET_FMA || TARGET_FMA4 || TARGET_AVX512F)"
   "@
    vfmsubadd132<ssemodesuffix>\t{%2, %3, %0|%0, %3, %2}
    vfmsubadd213<ssemodesuffix>\t{%3, %2, %0|%0, %2, %3}
            (match_operand:VF_128 3 "nonimmediate_operand" " v,vm"))
          (match_dup 1)
          (const_int 1)))]
-  "TARGET_FMA"
+  "TARGET_FMA || TARGET_AVX512F"
   "@
    vfmadd132<ssescalarmodesuffix>\t{%2, %3, %0|%0, %<iptr>3, %<iptr>2}
    vfmadd213<ssescalarmodesuffix>\t{%3, %2, %0|%0, %<iptr>2, %<iptr>3}"
              (match_operand:VF_128 3 "nonimmediate_operand" " v,vm")))
          (match_dup 1)
          (const_int 1)))]
-  "TARGET_FMA"
+  "TARGET_FMA || TARGET_AVX512F"
   "@
    vfmsub132<ssescalarmodesuffix>\t{%2, %3, %0|%0, %<iptr>3, %<iptr>2}
    vfmsub213<ssescalarmodesuffix>\t{%3, %2, %0|%0, %<iptr>2, %<iptr>3}"
            (match_operand:VF_128   3 "nonimmediate_operand" " v,vm"))
          (match_dup 1)
          (const_int 1)))]
-  "TARGET_FMA"
+  "TARGET_FMA || TARGET_AVX512F"
   "@
    vfnmadd132<ssescalarmodesuffix>\t{%2, %3, %0|%0, %<iptr>3, %<iptr>2}
    vfnmadd213<ssescalarmodesuffix>\t{%3, %2, %0|%0, %<iptr>2, %<iptr>3}"
              (match_operand:VF_128 3 "nonimmediate_operand" " v,vm")))
          (match_dup 1)
          (const_int 1)))]
-  "TARGET_FMA"
+  "TARGET_FMA || TARGET_AVX512F"
   "@
    vfnmsub132<ssescalarmodesuffix>\t{%2, %3, %0|%0, %<iptr>3, %<iptr>2}
    vfnmsub213<ssescalarmodesuffix>\t{%3, %2, %0|%0, %<iptr>2, %<iptr>3}"