From: Lingling Kong Date: Mon, 3 Jun 2024 03:00:03 +0000 (+0800) Subject: [APX NF] Support APX NF for {sub/and/or/xor/neg} X-Git-Tag: basepoints/gcc-16~8577 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=85a70b2536883c0ffa0f72d20638e0679acd9070;p=thirdparty%2Fgcc.git [APX NF] Support APX NF for {sub/and/or/xor/neg} gcc/ChangeLog: * config/i386/i386.md (nf_nonf_attr): New subst_attr. (nf_nonf_x64_attr): Ditto. (*sub_1): New define_insn. (*anddi_1): Ditto. (*and_1): Ditto. (*andqi_1): Ditto. (*_1): Ditto. (*qi_1): Ditto. (*neg_1): Ditto. * config/i386/sse.md: New define_split. gcc/testsuite/ChangeLog: * gcc.target/i386/apx-nf.c: New test. --- diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index 4b2d9e71c43..5653f5ce123 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -575,7 +575,7 @@ noavx512dq,fma_or_avx512vl,avx512vl,noavx512vl,avxvnni, avx512vnnivl,avx512fp16,avxifma,avx512ifmavl,avxneconvert, avx512bf16vl,vpclmulqdqvl,avx_noavx512f,avx_noavx512vl, - vaes_avx512vl" + vaes_avx512vl,noapx_nf" (const_string "base")) ;; The (bounding maximum) length of an instruction immediate. @@ -981,6 +981,7 @@ (symbol_ref "TARGET_MMX_WITH_SSE && !TARGET_AVX") (eq_attr "mmx_isa" "avx") (symbol_ref "TARGET_MMX_WITH_SSE && TARGET_AVX") + (eq_attr "isa" "noapx_nf") (symbol_ref "!TARGET_APX_NF") ] (const_int 1))) @@ -6449,6 +6450,8 @@ (define_subst_attr "nf_condition" "nf_subst" "TARGET_APX_NF" "true") (define_subst_attr "nf_mem_constraint" "nf_subst" "je" "m") (define_subst_attr "nf_applied" "nf_subst" "true" "false") +(define_subst_attr "nf_nonf_attr" "nf_subst" "noapx_nf" "*") +(define_subst_attr "nf_nonf_x64_attr" "nf_subst" "noapx_nf" "x64") (define_subst "nf_subst" [(set (match_operand:SWI 0) @@ -7895,20 +7898,21 @@ "split_double_mode (mode, &operands[0], 2, &operands[0], &operands[3]);" [(set_attr "isa" "*,*,apx_ndd,apx_ndd")]) -(define_insn "*sub_1" - [(set (match_operand:SWI 0 "nonimmediate_operand" "=m,,r,r,r") +(define_insn "*sub_1" + [(set (match_operand:SWI 0 "nonimmediate_operand" "=m,r,,r,r,r") (minus:SWI - (match_operand:SWI 1 "nonimmediate_operand" "0,0,rm,rjM,r") - (match_operand:SWI 2 "" ",,r,,"))) - (clobber (reg:CC FLAGS_REG))] - "ix86_binary_operator_ok (MINUS, mode, operands, TARGET_APX_NDD)" + (match_operand:SWI 1 "nonimmediate_operand" "0,0,0,rm,rjM,r") + (match_operand:SWI 2 "" ",,,r,,")))] + "ix86_binary_operator_ok (MINUS, mode, operands, TARGET_APX_NDD) + && " "@ - sub{}\t{%2, %0|%0, %2} - sub{}\t{%2, %0|%0, %2} - sub{}\t{%2, %1, %0|%0, %1, %2} - sub{}\t{%2, %1, %0|%0, %1, %2} - sub{}\t{%2, %1, %0|%0, %1, %2}" - [(set_attr "isa" "*,*,apx_ndd,apx_ndd,apx_ndd") + sub{}\t{%2, %0|%0, %2} + sub{}\t{%2, %0|%0, %2} + sub{}\t{%2, %0|%0, %2} + sub{}\t{%2, %1, %0|%0, %1, %2} + sub{}\t{%2, %1, %0|%0, %1, %2} + sub{}\t{%2, %1, %0|%0, %1, %2}" + [(set_attr "isa" "*,*,*,apx_ndd,apx_ndd,apx_ndd") (set_attr "type" "alu") (set_attr "mode" "")]) @@ -11797,27 +11801,28 @@ } [(set_attr "isa" "*,*,apx_ndd,apx_ndd,apx_ndd,apx_ndd_64,apx_ndd")]) -(define_insn "*anddi_1" - [(set (match_operand:DI 0 "nonimmediate_operand" "=r,r,rm,r,r,r,r,r,?k") +(define_insn "*anddi_1" + [(set (match_operand:DI 0 "nonimmediate_operand" "=r,r,rm,r,r,r,r,r,r,?k") (and:DI - (match_operand:DI 1 "nonimmediate_operand" "%0,r,0,0,rm,rjM,r,qm,k") - (match_operand:DI 2 "x86_64_szext_general_operand" "Z,Z,re,m,r,e,m,L,k"))) - (clobber (reg:CC FLAGS_REG))] + (match_operand:DI 1 "nonimmediate_operand" "%0,r,0,0,0,rm,rjM,r,qm,k") + (match_operand:DI 2 "x86_64_szext_general_operand" "Z,Z,r,e,m,r,e,m,L,k")))] "TARGET_64BIT - && ix86_binary_operator_ok (AND, DImode, operands, TARGET_APX_NDD)" + && ix86_binary_operator_ok (AND, DImode, operands, TARGET_APX_NDD) + && " "@ - and{l}\t{%k2, %k0|%k0, %k2} - and{l}\t{%k2, %k1, %k0|%k0, %k1, %k2} - and{q}\t{%2, %0|%0, %2} - and{q}\t{%2, %0|%0, %2} - and{q}\t{%2, %1, %0|%0, %1, %2} - and{q}\t{%2, %1, %0|%0, %1, %2} - and{q}\t{%2, %1, %0|%0, %1, %2} + and{l}\t{%k2, %k0|%k0, %k2} + and{l}\t{%k2, %k1, %k0|%k0, %k1, %k2} + and{q}\t{%2, %0|%0, %2} + and{q}\t{%2, %0|%0, %2} + and{q}\t{%2, %0|%0, %2} + and{q}\t{%2, %1, %0|%0, %1, %2} + and{q}\t{%2, %1, %0|%0, %1, %2} + and{q}\t{%2, %1, %0|%0, %1, %2} # #" - [(set_attr "isa" "x64,apx_ndd,x64,x64,apx_ndd,apx_ndd,apx_ndd,x64,avx512bw") - (set_attr "type" "alu,alu,alu,alu,alu,alu,alu,imovx,msklog") - (set_attr "length_immediate" "*,*,*,*,*,*,*,0,*") + [(set_attr "isa" "x64,apx_ndd,x64,x64,x64,apx_ndd,apx_ndd,apx_ndd,,avx512bw") + (set_attr "type" "alu,alu,alu,alu,alu,alu,alu,alu,imovx,msklog") + (set_attr "length_immediate" "*,*,*,*,*,*,*,*,0,*") (set (attr "prefix_rex") (if_then_else (and (eq_attr "type" "imovx") @@ -11825,7 +11830,7 @@ (match_operand 1 "ext_QIreg_operand"))) (const_string "1") (const_string "*"))) - (set_attr "mode" "SI,SI,DI,DI,DI,DI,DI,SI,DI")]) + (set_attr "mode" "SI,SI,DI,DI,DI,DI,DI,DI,SI,DI")]) (define_insn_and_split "*anddi_1_btr" [(set (match_operand:DI 0 "nonimmediate_operand" "=rm") @@ -11896,31 +11901,34 @@ (set_attr "isa" "*,apx_ndd,apx_ndd,apx_ndd") (set_attr "mode" "SI")]) -(define_insn "*and_1" - [(set (match_operand:SWI24 0 "nonimmediate_operand" "=rm,r,r,r,r,Ya,?k") - (and:SWI24 (match_operand:SWI24 1 "nonimmediate_operand" "%0,0,rm,rjM,r,qm,k") - (match_operand:SWI24 2 "" "r,,r,,,L,k"))) - (clobber (reg:CC FLAGS_REG))] - "ix86_binary_operator_ok (AND, mode, operands, TARGET_APX_NDD)" +(define_insn "*and_1" + [(set (match_operand:SWI24 0 "nonimmediate_operand" "=rm,r,r,r,r,r,Ya,?k") + (and:SWI24 (match_operand:SWI24 1 "nonimmediate_operand" "%0,0,0,rm,rjM,r,qm,k") + (match_operand:SWI24 2 "" "r,,,r,,,L,k")))] + "ix86_binary_operator_ok (AND, mode, operands, TARGET_APX_NDD) + && " "@ - and{}\t{%2, %0|%0, %2} - and{}\t{%2, %0|%0, %2} - and{}\t{%2, %1, %0|%0, %1, %2} - and{}\t{%2, %1, %0|%0, %1, %2} - and{}\t{%2, %1, %0|%0, %1, %2} + and{}\t{%2, %0|%0, %2} + and{}\t{%2, %0|%0, %2} + and{}\t{%2, %0|%0, %2} + and{}\t{%2, %1, %0|%0, %1, %2} + and{}\t{%2, %1, %0|%0, %1, %2} + and{}\t{%2, %1, %0|%0, %1, %2} # #" [(set (attr "isa") - (cond [(eq_attr "alternative" "2,3,4") + (cond [(eq_attr "alternative" "3,4,5") (const_string "apx_ndd") (eq_attr "alternative" "6") + (const_string "") + (eq_attr "alternative" "7") (if_then_else (eq_attr "mode" "SI") (const_string "avx512bw") (const_string "avx512f")) ] (const_string "*"))) - (set_attr "type" "alu,alu,alu,alu,alu,imovx,msklog") - (set_attr "length_immediate" "*,*,*,*,*,0,*") + (set_attr "type" "alu,alu,alu,alu,alu,alu,imovx,msklog") + (set_attr "length_immediate" "*,*,*,*,*,*,0,*") (set (attr "prefix_rex") (if_then_else (and (eq_attr "type" "imovx") @@ -11928,20 +11936,20 @@ (match_operand 1 "ext_QIreg_operand"))) (const_string "1") (const_string "*"))) - (set_attr "mode" ",,,,,SI,")]) + (set_attr "mode" ",,,,,,SI,")]) -(define_insn "*andqi_1" +(define_insn "*andqi_1" [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,q,r,r,r,?k") (and:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0,rm,r,k") - (match_operand:QI 2 "general_operand" "qn,m,rn,rn,m,k"))) - (clobber (reg:CC FLAGS_REG))] - "ix86_binary_operator_ok (AND, QImode, operands, TARGET_APX_NDD)" + (match_operand:QI 2 "general_operand" "qn,m,rn,rn,m,k")))] + "ix86_binary_operator_ok (AND, QImode, operands, TARGET_APX_NDD) + && " "@ - and{b}\t{%2, %0|%0, %2} - and{b}\t{%2, %0|%0, %2} - and{l}\t{%k2, %k0|%k0, %k2} - and{b}\t{%2, %1, %0|%0, %1, %2} - and{b}\t{%2, %1, %0|%0, %1, %2} + and{b}\t{%2, %0|%0, %2} + and{b}\t{%2, %0|%0, %2} + and{l}\t{%k2, %k0|%k0, %k2} + and{b}\t{%2, %1, %0|%0, %1, %2} + and{b}\t{%2, %1, %0|%0, %1, %2} #" [(set_attr "type" "alu,alu,alu,alu,alu,msklog") (set_attr "isa" "*,*,*,apx_ndd,apx_ndd,*") @@ -12804,22 +12812,23 @@ } [(set_attr "isa" "*,*,apx_ndd,apx_ndd,apx_ndd,apx_ndd_64,apx_ndd")]) -(define_insn "*_1" - [(set (match_operand:SWI248 0 "nonimmediate_operand" "=rm,r,r,r,r,?k") +(define_insn "*_1" + [(set (match_operand:SWI248 0 "nonimmediate_operand" "=rm,r,r,r,r,r,?k") (any_or:SWI248 - (match_operand:SWI248 1 "nonimmediate_operand" "%0,0,rm,rjM,r,k") - (match_operand:SWI248 2 "" "r,,r,,,k"))) - (clobber (reg:CC FLAGS_REG))] - "ix86_binary_operator_ok (, mode, operands, TARGET_APX_NDD)" + (match_operand:SWI248 1 "nonimmediate_operand" "%0,0,0,rm,rjM,r,k") + (match_operand:SWI248 2 "" "r,,,r,,,k")))] + "ix86_binary_operator_ok (, mode, operands, TARGET_APX_NDD) + && " "@ - {}\t{%2, %0|%0, %2} - {}\t{%2, %0|%0, %2} - {}\t{%2, %1, %0|%0, %1, %2} - {}\t{%2, %1, %0|%0, %1, %2} - {}\t{%2, %1, %0|%0, %1, %2} + {}\t{%2, %0|%0, %2} + {}\t{%2, %0|%0, %2} + {}\t{%2, %0|%0, %2} + {}\t{%2, %1, %0|%0, %1, %2} + {}\t{%2, %1, %0|%0, %1, %2} + {}\t{%2, %1, %0|%0, %1, %2} #" - [(set_attr "isa" "*,*,apx_ndd,apx_ndd,apx_ndd,") - (set_attr "type" "alu, alu, alu, alu, alu, msklog") + [(set_attr "isa" "*,*,*,apx_ndd,apx_ndd,apx_ndd,") + (set_attr "type" "alu,alu, alu, alu, alu, alu, msklog") (set_attr "mode" "")]) (define_insn_and_split "*notxor_1" @@ -12965,18 +12974,18 @@ (set_attr "isa" "*,apx_ndd") (set_attr "mode" "SI")]) -(define_insn "*qi_1" +(define_insn "*qi_1" [(set (match_operand:QI 0 "nonimmediate_operand" "=qm,q,r,r,r,?k") (any_or:QI (match_operand:QI 1 "nonimmediate_operand" "%0,0,0,rm,r,k") - (match_operand:QI 2 "general_operand" "qn,m,rn,rn,m,k"))) - (clobber (reg:CC FLAGS_REG))] - "ix86_binary_operator_ok (, QImode, operands, TARGET_APX_NDD)" + (match_operand:QI 2 "general_operand" "qn,m,rn,rn,m,k")))] + "ix86_binary_operator_ok (, QImode, operands, TARGET_APX_NDD) + && " "@ - {b}\t{%2, %0|%0, %2} - {b}\t{%2, %0|%0, %2} - {l}\t{%k2, %k0|%k0, %k2} - {b}\t{%2, %1, %0|%0, %1, %2} - {b}\t{%2, %1, %0|%0, %1, %2} + {b}\t{%2, %0|%0, %2} + {b}\t{%2, %0|%0, %2} + {l}\t{%k2, %k0|%k0, %k2} + {b}\t{%2, %1, %0|%0, %1, %2} + {b}\t{%2, %1, %0|%0, %1, %2} #" [(set_attr "isa" "*,*,*,apx_ndd,apx_ndd,avx512f") (set_attr "type" "alu,alu,alu,alu,alu,msklog") @@ -13536,14 +13545,14 @@ (const_int 0))) (clobber (reg:CC FLAGS_REG))])]) -(define_insn "*neg_1" +(define_insn "*neg_1" [(set (match_operand:SWI 0 "nonimmediate_operand" "=m,r") - (neg:SWI (match_operand:SWI 1 "nonimmediate_operand" "0,rm"))) - (clobber (reg:CC FLAGS_REG))] - "ix86_unary_operator_ok (NEG, mode, operands, TARGET_APX_NDD)" + (neg:SWI (match_operand:SWI 1 "nonimmediate_operand" "0,rm")))] + "ix86_unary_operator_ok (NEG, mode, operands, TARGET_APX_NDD) + && " "@ - neg{}\t%0 - neg{}\t{%1, %0|%0, %1}" + neg{}\t%0 + neg{}\t{%1, %0|%0, %1}" [(set_attr "type" "negnot") (set_attr "isa" "*,apx_ndd") (set_attr "mode" "")]) diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md index a5a7347f23a..ca560b639b8 100644 --- a/gcc/config/i386/sse.md +++ b/gcc/config/i386/sse.md @@ -1986,6 +1986,17 @@ ] (const_string "")))]) +(define_split + [(set (match_operand:SWI1248_AVX512BW 0 "mask_reg_operand") + (any_logic:SWI1248_AVX512BW + (match_operand:SWI1248_AVX512BW 1 "mask_reg_operand") + (match_operand:SWI1248_AVX512BW 2 "mask_reg_operand")))] + "TARGET_AVX512F && reload_completed" + [(parallel + [(set (match_dup 0) + (any_logic:SWI1248_AVX512BW (match_dup 1) (match_dup 2))) + (unspec [(const_int 0)] UNSPEC_MASKOP)])]) + (define_split [(set (match_operand:SWI1248_AVX512BW 0 "mask_reg_operand") (any_logic:SWI1248_AVX512BW diff --git a/gcc/testsuite/gcc.target/i386/apx-nf.c b/gcc/testsuite/gcc.target/i386/apx-nf.c new file mode 100644 index 00000000000..f33a994f0b7 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/apx-nf.c @@ -0,0 +1,12 @@ +/* { dg-do compile { target { ! ia32 } } } */ +/* { dg-options "-mapx-features=egpr,push2pop2,ndd,ppx,nf -march=x86-64 -O2" } */ +/* { dg-final { scan-assembler-times "\{nf\} and" 1 } } */ +/* { dg-final { scan-assembler-times "\{nf\} or" 1 } } */ + +struct B { unsigned bit0 : 1; unsigned bit1 : 1; }; + +void +foo (struct B *b) +{ + b->bit0 = b->bit0 | b->bit1; +}