Re: [PATCH 11/13] [APX EGPR] Handle legacy insns that only support GPR16 (3/5)
On Thu, Aug 31, 2023 at 5:31 PM Richard Biener via Gcc-patches wrote: > > On Thu, Aug 31, 2023 at 11:26 AM Richard Biener > wrote: > > > > On Thu, Aug 31, 2023 at 10:25 AM Hongyu Wang via Gcc-patches > > wrote: > > > > > > From: Kong Lingling > > > > > > Disable EGPR usage for below legacy insns in opcode map2/3 that have vex > > > but no evex counterpart. > > > > > > insn list: > > > 1. phminposuw/vphminposuw > > > 2. ptest/vptest > > > 3. roundps/vroundps, roundpd/vroundpd, > > >roundss/vroundss, roundsd/vroundsd > > > 4. pcmpestri/vpcmpestri, pcmpestrm/vpcmpestrm > > > 5. pcmpistri/vpcmpistri, pcmpistrm/vpcmpistrm > > > > How are GPRs involved in the above? Or did I misunderstand something? > > Following up myself - for the memory operand alternatives I guess. How about > simply disabling the memory alternatives when EGPR is active? Wouldn't > that simplify the initial patchset a lot? Re-enabling them when > deemed important > could be done as followup then? > There're instructions only support memory operand but don't support gpr32 (.i.e. xsave) We still need to handle them at the initial patch. > Richard. > > > > 6. aesimc/vaesimc, aeskeygenassist/vaeskeygenassist > > > > > > gcc/ChangeLog: > > > > > > * config/i386/i386-protos.h (x86_evex_reg_mentioned_p): New > > > prototype. > > > * config/i386/i386.cc (x86_evex_reg_mentioned_p): New > > > function. > > > * config/i386/i386.md (sse4_1_round2): Set attr gpr32 0 > > > and constraint Bt/BM to all non-evex alternatives, adjust > > > alternative outputs if evex reg is mentioned. > > > * config/i386/sse.md (_ptest): Set attr gpr32 0 > > > and constraint Bt/BM to all non-evex alternatives. > > > (ptesttf2): Likewise. > > > (_round > > (sse4_1_round): Likewise. > > > (sse4_2_pcmpestri): Likewise. > > > (sse4_2_pcmpestrm): Likewise. > > > (sse4_2_pcmpestr_cconly): Likewise. > > > (sse4_2_pcmpistr): Likewise. > > > (sse4_2_pcmpistri): Likewise. > > > (sse4_2_pcmpistrm): Likewise. > > > (sse4_2_pcmpistr_cconly): Likewise. > > > (aesimc): Likewise. > > > (aeskeygenassist): Likewise. > > > > > > gcc/testsuite/ChangeLog: > > > > > > * gcc.target/i386/apx-legacy-insn-check-norex2.c: Add intrinsic > > > tests. > > > --- > > > gcc/config/i386/i386-protos.h | 1 + > > > gcc/config/i386/i386.cc | 13 +++ > > > gcc/config/i386/i386.md | 3 +- > > > gcc/config/i386/sse.md| 93 +-- > > > .../i386/apx-legacy-insn-check-norex2.c | 55 ++- > > > 5 files changed, 132 insertions(+), 33 deletions(-) > > > > > > diff --git a/gcc/config/i386/i386-protos.h b/gcc/config/i386/i386-protos.h > > > index 78eb3e0f584..bbb219e3039 100644 > > > --- a/gcc/config/i386/i386-protos.h > > > +++ b/gcc/config/i386/i386-protos.h > > > @@ -65,6 +65,7 @@ extern bool extended_reg_mentioned_p (rtx); > > > extern bool x86_extended_QIreg_mentioned_p (rtx_insn *); > > > extern bool x86_extended_reg_mentioned_p (rtx); > > > extern bool x86_extended_rex2reg_mentioned_p (rtx); > > > +extern bool x86_evex_reg_mentioned_p (rtx [], int); > > > extern bool x86_maybe_negate_const_int (rtx *, machine_mode); > > > extern machine_mode ix86_cc_mode (enum rtx_code, rtx, rtx); > > > > > > diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc > > > index f5d642948bc..ec93c5bab97 100644 > > > --- a/gcc/config/i386/i386.cc > > > +++ b/gcc/config/i386/i386.cc > > > @@ -22936,6 +22936,19 @@ x86_extended_rex2reg_mentioned_p (rtx insn) > > >return false; > > > } > > > > > > +/* Return true when rtx operands mentions register that must be encoded > > > using > > > + evex prefix. */ > > > +bool > > > +x86_evex_reg_mentioned_p (rtx operands[], int nops) > > > +{ > > > + int i; > > > + for (i = 0; i < nops; i++) > > > +if (EXT_REX_SSE_REG_P (operands[i]) > > > + || x86_extended_rex2reg_mentioned_p (operands[i])) > > > + return true; > > > + return false; > > > +} > > > + > > > /* If profitable, negate (without causing overflow) integer constant > > > of mode MODE at location LOC. Return true in this case. */ > > > bool > > > diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md > > > index 83ad01b43c1..4c305e72389 100644 > > > --- a/gcc/config/i386/i386.md > > > +++ b/gcc/config/i386/i386.md > > > @@ -21603,7 +21603,7 @@ (define_expand "significand2" > > > (define_insn "sse4_1_round2" > > >[(set (match_operand:MODEFH 0 "register_operand" "=x,x,x,v,v") > > > (unspec:MODEFH > > > - [(match_operand:MODEFH 1 "nonimmediate_operand" "0,x,m,v,m") > > > + [(match_operand:MODEFH 1 "nonimmediate_operand" "0,x,Bt,v,m") > > >(match_operand:SI 2 "const_0_to_15_operand")] > > > UNSPEC_ROUND))] > > >"TARGET_SSE4_1" > > >
Re: [PATCH 11/13] [APX EGPR] Handle legacy insns that only support GPR16 (3/5)
Richard Biener via Gcc-patches 于2023年8月31日周四 17:31写道: > > On Thu, Aug 31, 2023 at 11:26 AM Richard Biener > wrote: > > > > On Thu, Aug 31, 2023 at 10:25 AM Hongyu Wang via Gcc-patches > > wrote: > > > > > > From: Kong Lingling > > > > > > Disable EGPR usage for below legacy insns in opcode map2/3 that have vex > > > but no evex counterpart. > > > > > > insn list: > > > 1. phminposuw/vphminposuw > > > 2. ptest/vptest > > > 3. roundps/vroundps, roundpd/vroundpd, > > >roundss/vroundss, roundsd/vroundsd > > > 4. pcmpestri/vpcmpestri, pcmpestrm/vpcmpestrm > > > 5. pcmpistri/vpcmpistri, pcmpistrm/vpcmpistrm > > > > How are GPRs involved in the above? Or did I misunderstand something? > > Following up myself - for the memory operand alternatives I guess. How about > simply disabling the memory alternatives when EGPR is active? Wouldn't > that simplify the initial patchset a lot? Re-enabling them when > deemed important > could be done as followup then? > It also require per-pattern change that set the attr isa for mem alternative with "noapx_egpr". We also have a series of patterns that some alternatives support EGPR and another does not. Like commonly used vec_set patterns, then we still need to identify the alternatives that if it is EGPR supported. > Richard. > > > > 6. aesimc/vaesimc, aeskeygenassist/vaeskeygenassist > > > > > > gcc/ChangeLog: > > > > > > * config/i386/i386-protos.h (x86_evex_reg_mentioned_p): New > > > prototype. > > > * config/i386/i386.cc (x86_evex_reg_mentioned_p): New > > > function. > > > * config/i386/i386.md (sse4_1_round2): Set attr gpr32 0 > > > and constraint Bt/BM to all non-evex alternatives, adjust > > > alternative outputs if evex reg is mentioned. > > > * config/i386/sse.md (_ptest): Set attr gpr32 0 > > > and constraint Bt/BM to all non-evex alternatives. > > > (ptesttf2): Likewise. > > > (_round > > (sse4_1_round): Likewise. > > > (sse4_2_pcmpestri): Likewise. > > > (sse4_2_pcmpestrm): Likewise. > > > (sse4_2_pcmpestr_cconly): Likewise. > > > (sse4_2_pcmpistr): Likewise. > > > (sse4_2_pcmpistri): Likewise. > > > (sse4_2_pcmpistrm): Likewise. > > > (sse4_2_pcmpistr_cconly): Likewise. > > > (aesimc): Likewise. > > > (aeskeygenassist): Likewise. > > > > > > gcc/testsuite/ChangeLog: > > > > > > * gcc.target/i386/apx-legacy-insn-check-norex2.c: Add intrinsic > > > tests. > > > --- > > > gcc/config/i386/i386-protos.h | 1 + > > > gcc/config/i386/i386.cc | 13 +++ > > > gcc/config/i386/i386.md | 3 +- > > > gcc/config/i386/sse.md| 93 +-- > > > .../i386/apx-legacy-insn-check-norex2.c | 55 ++- > > > 5 files changed, 132 insertions(+), 33 deletions(-) > > > > > > diff --git a/gcc/config/i386/i386-protos.h b/gcc/config/i386/i386-protos.h > > > index 78eb3e0f584..bbb219e3039 100644 > > > --- a/gcc/config/i386/i386-protos.h > > > +++ b/gcc/config/i386/i386-protos.h > > > @@ -65,6 +65,7 @@ extern bool extended_reg_mentioned_p (rtx); > > > extern bool x86_extended_QIreg_mentioned_p (rtx_insn *); > > > extern bool x86_extended_reg_mentioned_p (rtx); > > > extern bool x86_extended_rex2reg_mentioned_p (rtx); > > > +extern bool x86_evex_reg_mentioned_p (rtx [], int); > > > extern bool x86_maybe_negate_const_int (rtx *, machine_mode); > > > extern machine_mode ix86_cc_mode (enum rtx_code, rtx, rtx); > > > > > > diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc > > > index f5d642948bc..ec93c5bab97 100644 > > > --- a/gcc/config/i386/i386.cc > > > +++ b/gcc/config/i386/i386.cc > > > @@ -22936,6 +22936,19 @@ x86_extended_rex2reg_mentioned_p (rtx insn) > > >return false; > > > } > > > > > > +/* Return true when rtx operands mentions register that must be encoded > > > using > > > + evex prefix. */ > > > +bool > > > +x86_evex_reg_mentioned_p (rtx operands[], int nops) > > > +{ > > > + int i; > > > + for (i = 0; i < nops; i++) > > > +if (EXT_REX_SSE_REG_P (operands[i]) > > > + || x86_extended_rex2reg_mentioned_p (operands[i])) > > > + return true; > > > + return false; > > > +} > > > + > > > /* If profitable, negate (without causing overflow) integer constant > > > of mode MODE at location LOC. Return true in this case. */ > > > bool > > > diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md > > > index 83ad01b43c1..4c305e72389 100644 > > > --- a/gcc/config/i386/i386.md > > > +++ b/gcc/config/i386/i386.md > > > @@ -21603,7 +21603,7 @@ (define_expand "significand2" > > > (define_insn "sse4_1_round2" > > >[(set (match_operand:MODEFH 0 "register_operand" "=x,x,x,v,v") > > > (unspec:MODEFH > > > - [(match_operand:MODEFH 1 "nonimmediate_operand" "0,x,m,v,m") > > > + [(match_operand:MODEFH 1
Re: [PATCH 11/13] [APX EGPR] Handle legacy insns that only support GPR16 (3/5)
On Thu, Aug 31, 2023 at 11:26:26AM +0200, Richard Biener wrote: > On Thu, Aug 31, 2023 at 10:25 AM Hongyu Wang via Gcc-patches > wrote: > > > > From: Kong Lingling > > > > Disable EGPR usage for below legacy insns in opcode map2/3 that have vex > > but no evex counterpart. > > > > insn list: > > 1. phminposuw/vphminposuw > > 2. ptest/vptest > > 3. roundps/vroundps, roundpd/vroundpd, > >roundss/vroundss, roundsd/vroundsd > > 4. pcmpestri/vpcmpestri, pcmpestrm/vpcmpestrm > > 5. pcmpistri/vpcmpistri, pcmpistrm/vpcmpistrm > > How are GPRs involved in the above? Or did I misunderstand something? Those instructions allow memory operands, and say vptest (%r18), %xmm7 isn't supported. Jakub
Re: [PATCH 11/13] [APX EGPR] Handle legacy insns that only support GPR16 (3/5)
On Thu, Aug 31, 2023 at 11:26 AM Richard Biener wrote: > > On Thu, Aug 31, 2023 at 10:25 AM Hongyu Wang via Gcc-patches > wrote: > > > > From: Kong Lingling > > > > Disable EGPR usage for below legacy insns in opcode map2/3 that have vex > > but no evex counterpart. > > > > insn list: > > 1. phminposuw/vphminposuw > > 2. ptest/vptest > > 3. roundps/vroundps, roundpd/vroundpd, > >roundss/vroundss, roundsd/vroundsd > > 4. pcmpestri/vpcmpestri, pcmpestrm/vpcmpestrm > > 5. pcmpistri/vpcmpistri, pcmpistrm/vpcmpistrm > > How are GPRs involved in the above? Or did I misunderstand something? Following up myself - for the memory operand alternatives I guess. How about simply disabling the memory alternatives when EGPR is active? Wouldn't that simplify the initial patchset a lot? Re-enabling them when deemed important could be done as followup then? Richard. > > 6. aesimc/vaesimc, aeskeygenassist/vaeskeygenassist > > > > gcc/ChangeLog: > > > > * config/i386/i386-protos.h (x86_evex_reg_mentioned_p): New > > prototype. > > * config/i386/i386.cc (x86_evex_reg_mentioned_p): New > > function. > > * config/i386/i386.md (sse4_1_round2): Set attr gpr32 0 > > and constraint Bt/BM to all non-evex alternatives, adjust > > alternative outputs if evex reg is mentioned. > > * config/i386/sse.md (_ptest): Set attr gpr32 0 > > and constraint Bt/BM to all non-evex alternatives. > > (ptesttf2): Likewise. > > (_round > (sse4_1_round): Likewise. > > (sse4_2_pcmpestri): Likewise. > > (sse4_2_pcmpestrm): Likewise. > > (sse4_2_pcmpestr_cconly): Likewise. > > (sse4_2_pcmpistr): Likewise. > > (sse4_2_pcmpistri): Likewise. > > (sse4_2_pcmpistrm): Likewise. > > (sse4_2_pcmpistr_cconly): Likewise. > > (aesimc): Likewise. > > (aeskeygenassist): Likewise. > > > > gcc/testsuite/ChangeLog: > > > > * gcc.target/i386/apx-legacy-insn-check-norex2.c: Add intrinsic > > tests. > > --- > > gcc/config/i386/i386-protos.h | 1 + > > gcc/config/i386/i386.cc | 13 +++ > > gcc/config/i386/i386.md | 3 +- > > gcc/config/i386/sse.md| 93 +-- > > .../i386/apx-legacy-insn-check-norex2.c | 55 ++- > > 5 files changed, 132 insertions(+), 33 deletions(-) > > > > diff --git a/gcc/config/i386/i386-protos.h b/gcc/config/i386/i386-protos.h > > index 78eb3e0f584..bbb219e3039 100644 > > --- a/gcc/config/i386/i386-protos.h > > +++ b/gcc/config/i386/i386-protos.h > > @@ -65,6 +65,7 @@ extern bool extended_reg_mentioned_p (rtx); > > extern bool x86_extended_QIreg_mentioned_p (rtx_insn *); > > extern bool x86_extended_reg_mentioned_p (rtx); > > extern bool x86_extended_rex2reg_mentioned_p (rtx); > > +extern bool x86_evex_reg_mentioned_p (rtx [], int); > > extern bool x86_maybe_negate_const_int (rtx *, machine_mode); > > extern machine_mode ix86_cc_mode (enum rtx_code, rtx, rtx); > > > > diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc > > index f5d642948bc..ec93c5bab97 100644 > > --- a/gcc/config/i386/i386.cc > > +++ b/gcc/config/i386/i386.cc > > @@ -22936,6 +22936,19 @@ x86_extended_rex2reg_mentioned_p (rtx insn) > >return false; > > } > > > > +/* Return true when rtx operands mentions register that must be encoded > > using > > + evex prefix. */ > > +bool > > +x86_evex_reg_mentioned_p (rtx operands[], int nops) > > +{ > > + int i; > > + for (i = 0; i < nops; i++) > > +if (EXT_REX_SSE_REG_P (operands[i]) > > + || x86_extended_rex2reg_mentioned_p (operands[i])) > > + return true; > > + return false; > > +} > > + > > /* If profitable, negate (without causing overflow) integer constant > > of mode MODE at location LOC. Return true in this case. */ > > bool > > diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md > > index 83ad01b43c1..4c305e72389 100644 > > --- a/gcc/config/i386/i386.md > > +++ b/gcc/config/i386/i386.md > > @@ -21603,7 +21603,7 @@ (define_expand "significand2" > > (define_insn "sse4_1_round2" > >[(set (match_operand:MODEFH 0 "register_operand" "=x,x,x,v,v") > > (unspec:MODEFH > > - [(match_operand:MODEFH 1 "nonimmediate_operand" "0,x,m,v,m") > > + [(match_operand:MODEFH 1 "nonimmediate_operand" "0,x,Bt,v,m") > >(match_operand:SI 2 "const_0_to_15_operand")] > > UNSPEC_ROUND))] > >"TARGET_SSE4_1" > > @@ -21616,6 +21616,7 @@ (define_insn "sse4_1_round2" > >[(set_attr "type" "ssecvt") > > (set_attr "prefix_extra" "1,1,1,*,*") > > (set_attr "length_immediate" "1") > > + (set_attr "gpr32" "1,1,0,1,1") > > (set_attr "prefix" "maybe_vex,maybe_vex,maybe_vex,evex,evex") > > (set_attr "isa" "noavx512f,noavx512f,noavx512f,avx512f,avx512f") > > (set_attr "avx_partial_xmm_update" "false,false,true,false,true") > > diff
Re: [PATCH 11/13] [APX EGPR] Handle legacy insns that only support GPR16 (3/5)
On Thu, Aug 31, 2023 at 10:25 AM Hongyu Wang via Gcc-patches wrote: > > From: Kong Lingling > > Disable EGPR usage for below legacy insns in opcode map2/3 that have vex > but no evex counterpart. > > insn list: > 1. phminposuw/vphminposuw > 2. ptest/vptest > 3. roundps/vroundps, roundpd/vroundpd, >roundss/vroundss, roundsd/vroundsd > 4. pcmpestri/vpcmpestri, pcmpestrm/vpcmpestrm > 5. pcmpistri/vpcmpistri, pcmpistrm/vpcmpistrm How are GPRs involved in the above? Or did I misunderstand something? > 6. aesimc/vaesimc, aeskeygenassist/vaeskeygenassist > > gcc/ChangeLog: > > * config/i386/i386-protos.h (x86_evex_reg_mentioned_p): New > prototype. > * config/i386/i386.cc (x86_evex_reg_mentioned_p): New > function. > * config/i386/i386.md (sse4_1_round2): Set attr gpr32 0 > and constraint Bt/BM to all non-evex alternatives, adjust > alternative outputs if evex reg is mentioned. > * config/i386/sse.md (_ptest): Set attr gpr32 0 > and constraint Bt/BM to all non-evex alternatives. > (ptesttf2): Likewise. > (_round (sse4_1_round): Likewise. > (sse4_2_pcmpestri): Likewise. > (sse4_2_pcmpestrm): Likewise. > (sse4_2_pcmpestr_cconly): Likewise. > (sse4_2_pcmpistr): Likewise. > (sse4_2_pcmpistri): Likewise. > (sse4_2_pcmpistrm): Likewise. > (sse4_2_pcmpistr_cconly): Likewise. > (aesimc): Likewise. > (aeskeygenassist): Likewise. > > gcc/testsuite/ChangeLog: > > * gcc.target/i386/apx-legacy-insn-check-norex2.c: Add intrinsic > tests. > --- > gcc/config/i386/i386-protos.h | 1 + > gcc/config/i386/i386.cc | 13 +++ > gcc/config/i386/i386.md | 3 +- > gcc/config/i386/sse.md| 93 +-- > .../i386/apx-legacy-insn-check-norex2.c | 55 ++- > 5 files changed, 132 insertions(+), 33 deletions(-) > > diff --git a/gcc/config/i386/i386-protos.h b/gcc/config/i386/i386-protos.h > index 78eb3e0f584..bbb219e3039 100644 > --- a/gcc/config/i386/i386-protos.h > +++ b/gcc/config/i386/i386-protos.h > @@ -65,6 +65,7 @@ extern bool extended_reg_mentioned_p (rtx); > extern bool x86_extended_QIreg_mentioned_p (rtx_insn *); > extern bool x86_extended_reg_mentioned_p (rtx); > extern bool x86_extended_rex2reg_mentioned_p (rtx); > +extern bool x86_evex_reg_mentioned_p (rtx [], int); > extern bool x86_maybe_negate_const_int (rtx *, machine_mode); > extern machine_mode ix86_cc_mode (enum rtx_code, rtx, rtx); > > diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc > index f5d642948bc..ec93c5bab97 100644 > --- a/gcc/config/i386/i386.cc > +++ b/gcc/config/i386/i386.cc > @@ -22936,6 +22936,19 @@ x86_extended_rex2reg_mentioned_p (rtx insn) >return false; > } > > +/* Return true when rtx operands mentions register that must be encoded using > + evex prefix. */ > +bool > +x86_evex_reg_mentioned_p (rtx operands[], int nops) > +{ > + int i; > + for (i = 0; i < nops; i++) > +if (EXT_REX_SSE_REG_P (operands[i]) > + || x86_extended_rex2reg_mentioned_p (operands[i])) > + return true; > + return false; > +} > + > /* If profitable, negate (without causing overflow) integer constant > of mode MODE at location LOC. Return true in this case. */ > bool > diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md > index 83ad01b43c1..4c305e72389 100644 > --- a/gcc/config/i386/i386.md > +++ b/gcc/config/i386/i386.md > @@ -21603,7 +21603,7 @@ (define_expand "significand2" > (define_insn "sse4_1_round2" >[(set (match_operand:MODEFH 0 "register_operand" "=x,x,x,v,v") > (unspec:MODEFH > - [(match_operand:MODEFH 1 "nonimmediate_operand" "0,x,m,v,m") > + [(match_operand:MODEFH 1 "nonimmediate_operand" "0,x,Bt,v,m") >(match_operand:SI 2 "const_0_to_15_operand")] > UNSPEC_ROUND))] >"TARGET_SSE4_1" > @@ -21616,6 +21616,7 @@ (define_insn "sse4_1_round2" >[(set_attr "type" "ssecvt") > (set_attr "prefix_extra" "1,1,1,*,*") > (set_attr "length_immediate" "1") > + (set_attr "gpr32" "1,1,0,1,1") > (set_attr "prefix" "maybe_vex,maybe_vex,maybe_vex,evex,evex") > (set_attr "isa" "noavx512f,noavx512f,noavx512f,avx512f,avx512f") > (set_attr "avx_partial_xmm_update" "false,false,true,false,true") > diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md > index 05963de9219..456713b991a 100644 > --- a/gcc/config/i386/sse.md > +++ b/gcc/config/i386/sse.md > @@ -22617,11 +22617,12 @@ (define_insn "avx2_pblendd" > > (define_insn "sse4_1_phminposuw" >[(set (match_operand:V8HI 0 "register_operand" "=Yr,*x,x") > - (unspec:V8HI [(match_operand:V8HI 1 "vector_operand" "YrBm,*xBm,xm")] > + (unspec:V8HI [(match_operand:V8HI 1 "vector_operand" "YrBT,*xBT,xBt")] > UNSPEC_PHMINPOSUW))] >"TARGET_SSE4_1" >"%vphminposuw\t{%1,