This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [AVX]: Reformat i386.md/sse.md
On Mon, May 12, 2008 at 06:18:22AM -0700, H.J. Lu wrote:
> Hi Joey,
>
> It is a good idea. I have 2 comments below.
>
> On Mon, May 12, 2008 at 3:15 AM, Ye, Joey <joey.ye@intel.com> wrote:
> > HJ,
> >
> > How about this example patch to simplify attribute "prefix" setting in
> > each patterns:
> >
> > Index: gcc/config/i386/i386.md
> > ===================================================================
> > --- gcc/config/i386/i386.md (revision 135201)
> > +++ gcc/config/i386/i386.md (working copy)
> > @@ -401,11 +401,18 @@
> > ;; There are also additional prefixes in SSSE3.
> > (define_attr "prefix_extra" "" (const_int 0))
> >
> > +;; Attribute to be set in insn pattern, which will force
> > +;; attr "prefix" to "vex" if TARGET_AVX is true
> > +(define_attr "maybe_vex" "" (const_int 0))
> > +
> > ;; Prefix used: original or VEX.
> > (define_attr "prefix" "orig,vex"
> > (if_then_else (eq_attr "mode" "OI,V8SF,V4DF")
> > (const_string "vex")
> > - (const_string "orig")))
> > + (if_then_else (and (not (eq_attr "maybe_vex" "0"))
> > + (ne (symbol_ref "TARGET_AVX") (const_int 0)))
> > + (const_string "vex")
> > + (const_string "orig"))))
>
> Please use "cond" instead of "if_then_else".
>
> > ;; There is a 8bit immediate for VEX.
> > (define_attr "prefix_vex_imm8" "" (const_int 0))
> > @@ -16135,11 +16142,9 @@
> > "* return TARGET_AVX ? \"vrcpss\t{%1, %0, %0|%0, %0, %1}\"
> > : \"rcpss\t{%1, %0|%0, %1}\";"
> > [(set_attr "type" "sse")
> > - (set (attr "prefix")
> > - (if_then_else (ne (symbol_ref "TARGET_AVX") (const_int 0))
> > - (const_string "vex")
> > - (const_string "orig")))
> > - (set_attr "mode" "SF")])
> > + (set_attr "mode" "SF")
> > + (set_attr "maybe_vex" "1")
> > + ])
>
> Please put
>
> (set_attr "maybe_vex" "1")
>
> before
>
> (set_attr "mode" "SF")])
>
> so that we only add one line.
>
Hi Joey, Xuepeng,
I am checking in this patch instead. Please use maybe_vex for
new AVX changes and existing AVX patterns.
Thanks.
H.J.
----
2008-05-12 Joey Ye <joey.ye@intel.com>
H.J. Lu <hongjiu.lu@intel.com>
* config/i386/i386.md (prefix): Add maybe_vex.
(length): Handle maybe_vex.
(*cmpfp_i_mixed): Set prefix attribute to maybe_vex instead
of vex.
(*cmpfp_iu_mixed): Likewise.
(*extendsfdf2_mixed): Likewise.
(*truncdfsf_fast_mixed): Likewise.
(*truncdfsf_mixed): Likewise.
(*fop_sf_comm_mixed_avx): Likewise.
(*fop_sf_1_mixed_avx): Likewise.
(*fop_df_comm_mixed_avx): Likewise.
(*fop_df_1_mixed_avx): Likewise.
(*cmpfp_i_sse): Set prefix attribute to maybe_vex.
(*cmpfp_iu_sse): Likewise.
(*rcpsf2_sse): Likewise.
(*rsqrtsf2_sse): Likewise.
(*sqrt<mode>2_sse): Likewise.
Index: i386.md
===================================================================
--- i386.md (revision 135196)
+++ i386.md (working copy)
@@ -401,8 +401,8 @@
;; There are also additional prefixes in SSSE3.
(define_attr "prefix_extra" "" (const_int 0))
-;; Prefix used: original or VEX.
-(define_attr "prefix" "orig,vex"
+;; Prefix used: original, VEX or maybe VEX.
+(define_attr "prefix" "orig,vex,maybe_vex"
(if_then_else (eq_attr "mode" "OI,V8SF,V4DF")
(const_string "vex")
(const_string "orig")))
@@ -469,7 +469,9 @@
(plus (const_int 2)
(plus (attr "prefix_data16")
(attr "length_address")))
- (eq_attr "prefix" "vex")
+ (ior (eq_attr "prefix" "vex")
+ (and (eq_attr "prefix" "maybe_vex")
+ (ne (symbol_ref "TARGET_AVX") (const_int 0))))
(plus (attr "length_vex")
(plus (attr "prefix_vex_imm8")
(plus (attr "modrm")
@@ -1294,10 +1296,8 @@
(const_string "SF")
(const_string "DF")))
(set (attr "prefix")
- (if_then_else (and (eq_attr "alternative" "1")
- (ne (symbol_ref "TARGET_AVX")
- (const_int 0)))
- (const_string "vex")
+ (if_then_else (eq_attr "alternative" "1")
+ (const_string "maybe_vex")
(const_string "orig")))
(set_attr "athlon_decode" "vector")
(set_attr "amdfam10_decode" "direct")])
@@ -1315,10 +1315,7 @@
(if_then_else (match_operand:SF 1 "" "")
(const_string "SF")
(const_string "DF")))
- (set (attr "prefix")
- (if_then_else (ne (symbol_ref "TARGET_AVX") (const_int 0))
- (const_string "vex")
- (const_string "orig")))
+ (set_attr "prefix" "maybe_vex")
(set_attr "athlon_decode" "vector")
(set_attr "amdfam10_decode" "direct")])
@@ -1356,10 +1353,8 @@
(const_string "SF")
(const_string "DF")))
(set (attr "prefix")
- (if_then_else (and (eq_attr "alternative" "1")
- (ne (symbol_ref "TARGET_AVX")
- (const_int 0)))
- (const_string "vex")
+ (if_then_else (eq_attr "alternative" "1")
+ (const_string "maybe_vex")
(const_string "orig")))
(set_attr "athlon_decode" "vector")
(set_attr "amdfam10_decode" "direct")])
@@ -1377,10 +1372,7 @@
(if_then_else (match_operand:SF 1 "" "")
(const_string "SF")
(const_string "DF")))
- (set (attr "prefix")
- (if_then_else (ne (symbol_ref "TARGET_AVX") (const_int 0))
- (const_string "vex")
- (const_string "orig")))
+ (set_attr "prefix" "maybe_vex")
(set_attr "athlon_decode" "vector")
(set_attr "athlon_decode" "vector")
(set_attr "amdfam10_decode" "direct")])
@@ -4201,10 +4193,8 @@
}
[(set_attr "type" "fmov,fmov,ssecvt")
(set (attr "prefix")
- (if_then_else (and (eq_attr "alternative" "2")
- (ne (symbol_ref "TARGET_AVX")
- (const_int 0)))
- (const_string "vex")
+ (if_then_else (eq_attr "alternative" "2")
+ (const_string "maybe_vex")
(const_string "orig")))
(set_attr "mode" "SF,XF,DF")])
@@ -4352,10 +4342,8 @@
}
[(set_attr "type" "fmov,ssecvt")
(set (attr "prefix")
- (if_then_else (and (eq_attr "alternative" "2")
- (ne (symbol_ref "TARGET_AVX")
- (const_int 0)))
- (const_string "vex")
+ (if_then_else (eq_attr "alternative" "2")
+ (const_string "maybe_vex")
(const_string "orig")))
(set_attr "mode" "SF")])
@@ -4405,10 +4393,8 @@
[(set_attr "type" "fmov,multi,ssecvt")
(set_attr "unit" "*,i387,*")
(set (attr "prefix")
- (if_then_else (and (eq_attr "alternative" "2")
- (ne (symbol_ref "TARGET_AVX")
- (const_int 0)))
- (const_string "vex")
+ (if_then_else (eq_attr "alternative" "2")
+ (const_string "maybe_vex")
(const_string "orig")))
(set_attr "mode" "SF")])
@@ -15994,10 +15980,8 @@
(const_string "fmul")
(const_string "fop"))))
(set (attr "prefix")
- (if_then_else (and (eq_attr "alternative" "1")
- (ne (symbol_ref "TARGET_AVX")
- (const_int 0)))
- (const_string "vex")
+ (if_then_else (eq_attr "alternative" "1")
+ (const_string "maybe_vex")
(const_string "orig")))
(set_attr "mode" "SF")])
@@ -16093,10 +16077,8 @@
]
(const_string "fop")))
(set (attr "prefix")
- (if_then_else (and (eq_attr "alternative" "2")
- (ne (symbol_ref "TARGET_AVX")
- (const_int 0)))
- (const_string "vex")
+ (if_then_else (eq_attr "alternative" "2")
+ (const_string "maybe_vex")
(const_string "orig")))
(set_attr "mode" "SF")])
@@ -16135,10 +16117,7 @@
"* return TARGET_AVX ? \"vrcpss\t{%1, %0, %0|%0, %0, %1}\"
: \"rcpss\t{%1, %0|%0, %1}\";"
[(set_attr "type" "sse")
- (set (attr "prefix")
- (if_then_else (ne (symbol_ref "TARGET_AVX") (const_int 0))
- (const_string "vex")
- (const_string "orig")))
+ (set_attr "prefix" "maybe_vex")
(set_attr "mode" "SF")])
(define_insn "*fop_sf_1_avx"
@@ -16249,10 +16228,8 @@
(const_string "fmul")
(const_string "fop"))))
(set (attr "prefix")
- (if_then_else (and (eq_attr "alternative" "1")
- (ne (symbol_ref "TARGET_AVX")
- (const_int 0)))
- (const_string "vex")
+ (if_then_else (eq_attr "alternative" "1")
+ (const_string "maybe_vex")
(const_string "orig")))
(set_attr "mode" "DF")])
@@ -16349,10 +16326,8 @@
]
(const_string "fop")))
(set (attr "prefix")
- (if_then_else (and (eq_attr "alternative" "2")
- (ne (symbol_ref "TARGET_AVX")
- (const_int 0)))
- (const_string "vex")
+ (if_then_else (eq_attr "alternative" "2")
+ (const_string "maybe_vex")
(const_string "orig")))
(set_attr "mode" "DF")])
@@ -16726,10 +16701,7 @@
"* return TARGET_AVX ? \"vrsqrtss\t{%1, %0, %0|%0, %0, %1}\"
: \"rsqrtss\t{%1, %0|%0, %1}\";"
[(set_attr "type" "sse")
- (set (attr "prefix")
- (if_then_else (ne (symbol_ref "TARGET_AVX") (const_int 0))
- (const_string "vex")
- (const_string "orig")))
+ (set_attr "prefix" "maybe_vex")
(set_attr "mode" "SF")])
(define_expand "rsqrtsf2"
@@ -16751,10 +16723,7 @@
: \"sqrts<ssemodefsuffix>\t{%1, %0|%0, %1}\";"
[(set_attr "type" "sse")
(set_attr "mode" "<MODE>")
- (set (attr "prefix")
- (if_then_else (ne (symbol_ref "TARGET_AVX") (const_int 0))
- (const_string "vex")
- (const_string "orig")))
+ (set_attr "prefix" "maybe_vex")
(set_attr "athlon_decode" "*")
(set_attr "amdfam10_decode" "*")])