Re: [PATCH] S/390: Remove UNSPEC_LTREL_BASE

2018-09-06 Thread Andreas Krebbel
On 14.08.2018 16:21, Ilya Leoshkevich wrote:
> It was needed only for g5/g6 machines, which are now gone.

gcc/ChangeLog:

2018-08-14  Ilya Leoshkevich  

* config/s390/s390.c (s390_decompose_constant_pool_ref):
Remove UNSPEC_LTREL_BASE check.
(annotate_constant_pool_refs): Likewise.
(find_constant_pool_ref): Likewise.
(find_ltrel_base): Removed.
(replace_ltrel_base): Removed.
(s390_mainpool_finish): Remove replace_ltrel_base call.
(s390_chunkify_start): Remove pending LTREL_BASE logic.
(s390_chunkify_finish): Remove replace_ltrel_base call.
* config/s390/s390.md: Remove UNSPEC_LTREL_BASE.

Committed. Thanks!

Andreas



Re: [PATCH 1/2] S/390: Register pass_s390_early_mach statically

2018-09-06 Thread Andreas Krebbel
gcc/ChangeLog:

2018-08-27  Ilya Leoshkevich  

PR target/80080
* config/s390/s390-passes.def: New file.
* config/s390/s390-protos.h (class rtl_opt_pass): Add forward
declaration.
(make_pass_s390_early_mach): Add declaration.
* config/s390/s390.c (make_pass_s390_early_mach):
(s390_option_override): Remove dynamic registration.
* config/s390/t-s390: Add s390-passes.def.


Committed. Thanks!

Andreas



Re: [PATCH] S/390: Prohibit SYMBOL_REF in UNSPECV_CAS

2018-09-06 Thread Andreas Krebbel
On 05.09.2018 22:22, Ilya Leoshkevich wrote:
> Inhibit constant propagation inlining SYMBOL_REF loads into
> UNSPECV_CAS.  Even though reload can later undo it, the resulting
> code will be less efficient.
> 
> gcc/ChangeLog:
> 
> 2018-09-05  Ilya Leoshkevich  
> 
>   PR target/80080
>   * config/s390/predicates.md: Add nonsym_memory_operand.
>   * config/s390/s390.c (s390_legitimize_cs_operand): If operand
>   contains a SYMBOL_REF, load it into an intermediate pseudo.
>   (s390_emit_compare_and_swap): Legitimize operand.
>   * config/s390/s390.md: Use the new nonsym_memory_operand
>   with UNSPECV_CAS patterns.

Committed. Thanks!

Andreas



Re: [PATCH] S/390: Fix conditional returns

2018-09-06 Thread Andreas Krebbel
Hi Ilya,

the S/390 parts look good to me. For the rest we will need approval from a 
middle-end maintainer.

Andreas

On 05.09.2018 10:34, Ilya Leoshkevich wrote:
> S/390 epilogue ends with (parallel [(return) (use %r14)]) instead of
> the more usual (return) or (simple_return).  This sequence is not
> recognized by the conditional return logic in try_optimize_cfg ().
> 
> gcc/ChangeLog:
> 
> 2018-08-28  Ilya Leoshkevich  
> 
>   PR target/80080
>   * cfgcleanup.c (bb_is_just_return): Accept PARALLELs containing
>   RETURNs.
>   * cfgrtl.c (rtl_verify_bb_layout): Handle PARALLELs containing
>   conditional jumps.
>   * config/s390/s390.md: Recognize PARALLELs containing RETURNs.
>   * jump.c (copy_update_parallel): Create a copy of a PARALLEL
>   in which one of side effects is replaced.
>   (redirect_exp_1): Handle jump targets that are PARALLELs
>   containing RETURNs.
>   (redirect_jump_2): Likewise.
>   (return_in_parallel): Recognize PARALLELs containing RETURNs.
>   * rtl.h (return_in_parallel): Add declaration.
> 
> gcc/testsuite/ChangeLog:
> 
> 2018-08-28  Ilya Leoshkevich  
> 
>   PR target/80080
>   * gcc.target/s390/risbg-ll-3.c: Expect conditional returns.
>   * gcc.target/s390/zvector/vec-cmp-2.c: Likewise.
> ---
>  gcc/cfgcleanup.c  |  2 +-
>  gcc/cfgrtl.c  |  3 +-
>  gcc/config/s390/s390.md   | 13 +++-
>  gcc/jump.c| 69 ++-
>  gcc/rtl.h |  1 +
>  gcc/testsuite/gcc.target/s390/risbg-ll-3.c|  4 +-
>  .../gcc.target/s390/zvector/vec-cmp-2.c   | 48 ++---
>  7 files changed, 108 insertions(+), 32 deletions(-)
> 
> diff --git a/gcc/cfgcleanup.c b/gcc/cfgcleanup.c
> index 4a5dc29d14f..7f2545f453f 100644
> --- a/gcc/cfgcleanup.c
> +++ b/gcc/cfgcleanup.c
> @@ -2624,7 +2624,7 @@ bb_is_just_return (basic_block bb, rtx_insn **ret, 
> rtx_insn **use)
>{
>   rtx pat = PATTERN (insn);
>  
> - if (!*ret && ANY_RETURN_P (pat))
> + if (!*ret && (ANY_RETURN_P (pat) || return_in_parallel (pat)))
> *ret = insn;
>   else if (!*ret && !*use && GET_CODE (pat) == USE
>   && REG_P (XEXP (pat, 0))
> diff --git a/gcc/cfgrtl.c b/gcc/cfgrtl.c
> index 3b1931daeba..701c6a985b8 100644
> --- a/gcc/cfgrtl.c
> +++ b/gcc/cfgrtl.c
> @@ -2987,7 +2987,8 @@ rtl_verify_bb_layout (void)
>   }
>  
>if (JUMP_P (x)
> -   && returnjump_p (x) && ! condjump_p (x)
> +   && returnjump_p (x)
> +   && ! (condjump_p (x) || condjump_in_parallel_p (x))
> && ! ((y = next_nonnote_nondebug_insn (x))
>   && BARRIER_P (y)))
>   fatal_insn ("return not followed by barrier", x);
> diff --git a/gcc/config/s390/s390.md b/gcc/config/s390/s390.md
> index db260e41bfd..3c413638038 100644
> --- a/gcc/config/s390/s390.md
> +++ b/gcc/config/s390/s390.md
> @@ -8842,8 +8842,19 @@
> (set_attr "type"  "branch")
> (set_attr "atype" "agen")])
>  
> +(define_subst "add_use_return_reg_subst"
> +  [(set (match_operand 0 "" "")
> + (match_operand 1 "" ""))]
> +  ""
> +  [(set (match_dup 0)
> + (match_dup 1))
> +   (use (reg RETURN_REGNUM))])
> +
> +(define_subst_attr "add_use_return_reg_name" "add_use_return_reg_subst"
> +"" "_use_return_reg")
> +
>  ;; A conditional return instruction.
> -(define_insn "*c"
> +(define_insn "*c"
>[(set (pc)
>  (if_then_else
>(match_operator 0 "s390_comparison" [(reg CC_REGNUM) (const_int 
> 0)])
> diff --git a/gcc/jump.c b/gcc/jump.c
> index 06f7255d24d..8057ace74d2 100644
> --- a/gcc/jump.c
> +++ b/gcc/jump.c
> @@ -1423,6 +1423,26 @@ redirect_target (rtx x)
>return x;
>  }
>  
> +/* Create a copy of PARALLEL with side-effect OSIDE replaced by NSIDE.  */
> +static rtx
> +copy_update_parallel (rtx par, rtx *oside, rtx nside)
> +{
> +  rtx npar;
> +  int i;
> +
> +  npar = gen_rtx_PARALLEL (GET_MODE (par), rtvec_alloc (XVECLEN (par, 0)));
> +  for (i = XVECLEN (par, 0) - 1; i >= 0; i--)
> +{
> +  rtx *side_effect = &XVECEXP (par, 0, i);
> +
> +  if (side_effect == oside)
> + XVECEXP (npar, 0, i) = nside;
> +  else
> + XVECEXP (npar, 0, i) = copy_rtx (*side_effect);
> +}
> +  return npar;
> +}
> +
>  /* Throughout LOC, redirect OLABEL to NLABEL.  Treat null OLABEL or
> NLABEL as a return.  Accrue modifications into the change group.  */
>  
> @@ -1437,9 +1457,22 @@ redirect_exp_1 (rtx *loc, rtx olabel, rtx nlabel, 
> rtx_insn *insn)
>if ((code == LABEL_REF && label_ref_label (x) == olabel)
>|| x == olabel)
>  {
> -  x = redirect_target (nlabel);
> -  if (GET_CODE (x) == LABEL_REF && loc == &PATTERN (insn))
> - x = gen_rtx_SET (pc_rtx, x);
> +  rtx *nret = return_in_parallel (nlabel);
> +
> +  if (nret)
> + {
> +   rtx npat;
> +
> +   x = *nret;
> +   npat = copy_upda

[PATCH 1/2] zEC12 pipeline

2018-09-06 Thread Robin Dapp

Hi,

this patch increases the latency of some floating point instructions to better
match the real machine's behavior.

Regards
 Robin

--

gcc/ChangeLog:

2018-09-06  Robin Dapp  

* config/s390/2827.md: Increase latencies for some FP instructions.
---
 gcc/config/s390/2827.md | 14 +-
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/gcc/config/s390/2827.md b/gcc/config/s390/2827.md
index a709a2e9f46..1fef0bbb597 100644
--- a/gcc/config/s390/2827.md
+++ b/gcc/config/s390/2827.md
@@ -38,9 +38,13 @@
   (and (eq_attr "cpu" "zEC12")
(eq_attr "mnemonic" "ltg,ogrk,lr,lghrl,x,asi,lhr,ar,lhrl,llgfr,clghrl,cgr,cli,agrk,ic,lrv,clg,cy,cghi,sy,clgfr,al,tm,lang,lghr,laa,ark,lh,or,icy,xi,n,llihl,afi,cs,nrk,sth,lgr,l,lcr,stey,xg,crt,slgfr,ny,ld,j,llihh,slgr,clfhsi,slg,lb,lgrl,lrl,llihf,llcr,laxg,mvghi,rllg,xrk,laag,alhsik,algfi,algr,aly,agfi,lrvr,d,crl,llgc,tmhl,algsi,lgh,icmh,clhrl,xgrk,icm,iilf,ork,cg,ldgr,lgf,iihf,llghr,sg,stam,tmhh,slgf,basr,lgb,cgfi,lax,clfit,lrvgr,nihl,ni,srdl,srk,xihf,stgrl,sthrl,algf,cgit,ng,lat,llghrl,ltgr,nihh,clgfrl,srlk,agr,ler,bcr_flush,stcy,cds,clfi,nihf,ly,clt,lgat,alg,lhy,lgfrl,clghsi,clrt,tmll,srlg,ay,sty,clr,lgfi,lan,clgt,ahik,sra,algrk,clgr,tmy,tmlh,alghsik,lcgr,mvi,ltgf,xr,larl,ldr,llgcr,clgrt,clrl,cghsi,cliy,oy,ogr,llgt,slr,chi,s,icmy,llc,ngr,clhhsi,ltgfr,llill,lhi,o,sll,clgrl,clgf,mviy,algfr,rll,sldl,lg,niy,st,sgr,ag,le,xgr,cr,stg,llilh,sr,cdsg,sllk,stoc,csg,clgit,chhsi,strl,llilf,lndfr,ngrk,clgfi,llgh,oill,la,llhrl,stc,lghi,oihl,xiy,sllg,llgf,cgrt,cl,sl,oi,oilh,nr,sra
 k,oihh,ear,slgrk,og,c,slgfi,sthy,oilf,oiy,oihf,a,cfi,srag,brasl,alr,cgrl,llgfrl,cit,ley,exrl,lcdfr,lay,xilf,alsi,mvhhi,srl,chsi,lgfr,lrvg,cly,sgrk,ahi,nill,jg,slrk,lxr,sar,slfi,cpsdr,lcgfr,aghik,nilh,mvhi,lpdfr,xy,alrk,lao,agsi,ldy,nilf,llhr,alfi,laog,sly,aghi,bras,srda,lt,lbr,lzxr,lzdr,lzer")) "nothing")
 
-(define_insn_reservation "zEC12_simple_fp" 1
+(define_insn_reservation "zEC12_simple_fp" 0
   (and (eq_attr "cpu" "zEC12")
-   (eq_attr "mnemonic" "lnebr,sdbr,sebr,clfxtr,adbr,aebr,celfbr,clfebr,lpebr,msebr,lndbr,clfdbr,llgtr,cebr,lgbr,maebr,ltebr,clfdtr,ltr,cdlgbr,cxlftr,lpdbr,cdfbr,lcebr,clfxbr,msdbr,cdbr,madbr,meebr,clgxbr,clgdtr,ledbr,cegbr,cdlftr,cdlgtr,mdbr,clgebr,ltdbr,cdlfbr,cdgbr,clgxtr,lcdbr,celgbr,clgdbr,ldebr,cefbr,fidtr,fixtr,madb,msdb,mseb,fiebra,fidbra,fixbra,aeb,mdb,seb,cdb,tcdb,sdb,adb,tceb,maeb,ceb,meeb,ldeb")) "nothing")
+   (eq_attr "mnemonic" "llgtr,lgbr,ltr")) "nothing")
+
+(define_insn_reservation "zEC12_normal_fp" 8
+  (and (eq_attr "cpu" "zEC12")
+   (eq_attr "mnemonic" "lnebr,sdbr,sebr,clfxtr,adbr,aebr,celfbr,clfebr,lpebr,msebr,lndbr,clfdbr,cebr,maebr,ltebr,clfdtr,cdlgbr,cxlftr,lpdbr,cdfbr,lcebr,clfxbr,msdbr,cdbr,madbr,meebr,clgxbr,clgdtr,ledbr,cegbr,cdlftr,cdlgtr,mdbr,clgebr,ltdbr,cdlfbr,cdgbr,clgxtr,lcdbr,celgbr,clgdbr,ldebr,cefbr,fidtr,fixtr,madb,msdb,mseb,fiebra,fidbra,aeb,mdb,seb,cdb,tcdb,sdb,adb,tceb,maeb,ceb,meeb,ldeb")) "nothing")
 
 (define_insn_reservation "zEC12_cgdbr" 2
   (and (eq_attr "cpu" "zEC12")
@@ -294,7 +298,7 @@
   (and (eq_attr "cpu" "zEC12")
(eq_attr "mnemonic" "locgr")) "nothing")
 
-(define_insn_reservation "zEC12_debr" 23
+(define_insn_reservation "zEC12_debr" 29
   (and (eq_attr "cpu" "zEC12")
(eq_attr "mnemonic" "debr")) "nothing")
 
@@ -422,7 +426,7 @@
   (and (eq_attr "cpu" "zEC12")
(eq_attr "mnemonic" "cxbr")) "nothing")
 
-(define_insn_reservation "zEC12_ddbr" 30
+(define_insn_reservation "zEC12_ddbr" 36
   (and (eq_attr "cpu" "zEC12")
(eq_attr "mnemonic" "ddbr")) "nothing")
 
@@ -430,7 +434,7 @@
   (and (eq_attr "cpu" "zEC12")
(eq_attr "mnemonic" "stmy")) "nothing")
 
-(define_insn_reservation "zEC12_ste" 3
+(define_insn_reservation "zEC12_ste" 4
   (and (eq_attr "cpu" "zEC12")
(eq_attr "mnemonic" "ste")) "nothing")
 


[PATCH 2/2] z13 pipeline

2018-09-06 Thread Robin Dapp

Similar to zEC12, the change in latencies helps match the real machine's
behavior better.

--

gcc/ChangeLog:

2018-09-06  Robin Dapp  

* config/s390/2964.md: Increase latencies for some FP instructions.
---
 gcc/config/s390/2964.md | 80 ++---
 1 file changed, 43 insertions(+), 37 deletions(-)

diff --git a/gcc/config/s390/2964.md b/gcc/config/s390/2964.md
index a91a272a250..3154a3cf325 100644
--- a/gcc/config/s390/2964.md
+++ b/gcc/config/s390/2964.md
@@ -113,7 +113,7 @@ fixtr,vaccb,wfadb,vaccf,vaccg,vacch,vnot,vmalob,vaccq,vmalof,vmaloh,lpxbr,\
 ledtr,vuplb,vuplf,axbr,lxdbr,ltxbr,vpopct,vpdi,vmlhb,vmlhf,vmlhh,sdbr,vnc,\
 vsumb,vsrab,vsumh,vmaob,vmaof,vmaoh,vesrlvb,vesrlvf,vesrlvg,vesrlvh,tcxb,\
 vceqbs,vceqh,lnxbr,sxbr,vesrab,wflcdb,vesraf,vesrag,vesrah,vflpdb,vmnh,\
-vsbiq,adtr,vsra,vsrl,vuplhb,sdb,vuplhf,vuplhh,vsumgf,vsumgh,ldebr,vuplhw,\
+vsbiq,adtr,vsra,vsrl,vuplhb,sdb,vuplhf,vuplhh,vsumgf,vsumgh,vuplhw,\
 vchfs,madb,ddbr") (const_int 1)]
 (const_int 0)))
 
@@ -145,50 +145,50 @@ ogr,popcnt,alcg,lndfr,larl,sll,tmy,ic,lpdfr,tend,lnr,bcr_flush")) "nothing")
 
 (define_insn_reservation "z13_1" 1
   (and (eq_attr "cpu" "z13")
-   (eq_attr "mnemonic" "celgbr,vscef,vsceg,msy,msgf,cxlftr,cdsg,cdsy,\
-exrl,clfebr,cefbr,chhsi,stam,vgef,vgeg,cdlftr,lam,mfy,lcgfr,cfdbr,dsgf,\
-cgdbr,lzxr,lmg,cfxbr,rnsbg,cxlgtr,mr,dl,cxftr,sldl,cgdtr,cegbr,rxsbg,ex,\
-cgxtr,clfxtr,mlgr,cdlgtr,brasl,dsg,efpc,cfebr,tbeginc,celfbr,clgxbr,vsteb,\
-vsteh,cxlfbr,clfdtr,cxgtr,stmg,stmy,stm,lm,cds,cdfbr,ml,ms,lngfr,clgebr,\
-stpq,lmy,cs,lpgfr,cdlgbr,lpq,cxfbr,cxlgbr,cdgtr,d,m,mlg,mlr,cgxbr,cdftr,\
-msgr,rosbg,clgdbr,cdgbr,srda,bras,srdl,tbegin,clfdbr,cdlfbr,cxgbr,cgebr,\
-dlg,clfxbr,lxr,csy,msgfi,msgfr,msg,flogr,msr,csg,msfi,clgdtr,clgxtr")) "nothing")
+   (eq_attr "mnemonic" "vscef,vsceg,msy,msgf,cdsg,cdsy,\
+exrl,chhsi,stam,vgef,vgeg,lam,mfy,lcgfr,cfdbr,dsgf,\
+cgdbr,lzxr,lmg,cfxbr,rnsbg,cxlgtr,mr,dl,cxftr,sldl,cgdtr,rxsbg,ex,\
+cgxtr,mlgr,brasl,dsg,efpc,cfebr,tbeginc,vsteb,\
+vsteh,cxlfbr,cxgtr,stmg,stmy,stm,lm,cds,ml,ms,lngfr,\
+stpq,lmy,cs,lpgfr,lpq,cxfbr,cxlgbr,cdgtr,d,m,mlg,mlr,cgxbr,cdftr,\
+msgr,rosbg,srda,bras,srdl,tbegin,cxgbr,cgebr,\
+dlg,lxr,csy,msgfi,msgfr,msg,flogr,msr,csg,msfi")) "nothing")
 
 (define_insn_reservation "z13_2" 2
   (and (eq_attr "cpu" "z13")
-   (eq_attr "mnemonic" "seb,vcksm,vfadb,vleib,vchgs,vleif,vleig,vleih,\
-vgbm,verimb,vone,verimf,verimg,verimh,verllvb,lpebr,verllvf,verllvg,verllvh,\
-vfeneb,wcdgb,vfenef,vfeneh,vchhs,vctzb,vctzf,vctzg,vctzh,vlcb,aeb,vlcf,\
-vlcg,vlch,vfmsdb,vgfmab,ltebr,vgfmaf,vgfmag,vgfmah,vmaeh,vsb,vsf,vsg,vsh,\
-vsl,vsq,lxebr,cdtr,fiebr,vupllb,vupllf,vupllh,vmrhb,madbr,vtm,vmrhf,vmrhg,\
-vmrhh,axtr,fiebra,vleb,cxtr,vlef,vleg,vleh,vpkf,vpkg,vpkh,vmlob,vmlof,vmloh,\
-lxdb,ldeb,vceqfs,adb,wflndb,lxeb,vn,vo,vchlb,vx,vchlf,vchlg,vchlh,vfcedbs,\
-vfcedb,vceqgs,cxbr,msdbr,vcdgb,vceqhs,meeb,lcxbr,vavglb,vavglf,vavglg,vavglh,\
-vmrlb,vmrlf,vmrlg,vmrlh,vmxb,tcdb,vmahh,vsrlb,wcgdb,lcdbr,\
+   (eq_attr "mnemonic" "vcksm,vfadb,vleib,vchgs,vleif,vleig,vleih,\
+vgbm,verimb,vone,verimf,verimg,verimh,verllvb,verllvf,verllvg,verllvh,\
+vfeneb,wcdgb,vfenef,vfeneh,vchhs,vctzb,vctzf,vctzg,vctzh,vlcb,vlcf,\
+vlcg,vlch,vfmsdb,vgfmab,vgfmaf,vgfmag,vgfmah,vmaeh,vsb,vsf,vsg,vsh,\
+vsl,vsq,lxebr,cdtr,fiebr,vupllb,vupllf,vupllh,vmrhb,vtm,vmrhf,vmrhg,\
+vmrhh,axtr,vleb,cxtr,vlef,vleg,vleh,vpkf,vpkg,vpkh,vmlob,vmlof,vmloh,\
+lxdb,vceqfs,wflndb,lxeb,vn,vo,vchlb,vx,vchlf,vchlg,vchlh,vfcedbs,\
+vfcedb,vceqgs,cxbr,vcdgb,vceqhs,lcxbr,vavglb,vavglf,vavglg,vavglh,\
+vmrlb,vmrlf,vmrlg,vmrlh,vmxb,vmahh,vsrlb,wcgdb,\
 vistrbs,vrepb,wfmdb,vrepf,vrepg,vreph,ler,wcdlgb,ley,vistrb,vistrf,vistrh,\
-tceb,vsumqf,vsumqg,vesrlb,vfeezbs,maebr,vesrlf,vesrlg,vesrlh,vmeb,vmef,\
-vmeh,meebr,vflcdb,wfmadb,vperm,sxtr,vclzf,vgm,vgmb,vgmf,vgmg,vgmh,tdcxt,\
-vzero,msebr,veslb,veslf,veslg,vfenezb,vfenezf,vfenezh,vistrfs,vchf,vchg,\
-vchh,vmhb,vmhf,vmhh,cdb,veslvb,ledbr,veslvf,veslvg,veslvh,wclgdb,vfmdb,\
-vmnlb,vmnlf,vmnlg,vmnlh,vclzb,vfeezfs,vclzg,vclzh,mdb,vmxlb,vmxlf,vmxlg,\
-vmxlh,ltdtr,vsbcbiq,ceb,sebr,vistrhs,lxdtr,lcebr,vab,vaf,vag,vah,ltxtr,\
-vlpf,vlpg,vsegb,vaq,vsegf,vsegh,sdtr,cdbr,vfeezhs,le,wldeb,vfmadb,\
-vchlbs,vacccq,vmaleb,vsel,vmalef,vmaleh,vflndb,mdbr,vmlb,wflpdb,ldetr,vpksfs,\
+vsumqf,vsumqg,vesrlb,vfeezbs,vesrlf,vesrlg,vesrlh,vmeb,vmef,\
+vmeh,vflcdb,wfmadb,vperm,sxtr,vclzf,vgm,vgmb,vgmf,vgmg,vgmh,tdcxt,\
+vzero,veslb,veslf,veslg,vfenezb,vfenezf,vfenezh,vistrfs,vchf,vchg,\
+vchh,vmhb,vmhf,vmhh,veslvb,veslvf,veslvg,veslvh,wclgdb,vfmdb,\
+vmnlb,vmnlf,vmnlg,vmnlh,vclzb,vfeezfs,vclzg,vclzh,vmxlb,vmxlf,vmxlg,\
+vmxlh,ltdtr,vsbcbiq,vistrhs,lxdtr,vab,vaf,vag,vah,ltxtr,\
+vlpf,vlpg,vsegb,vaq,vsegf,vsegh,sdtr,vfeezhs,le,wldeb,vfmadb,\
+vchlbs,vacccq,vmaleb,vsel,vmalef,vmaleh,vflndb,vmlb,wflpdb,ldetr,vpksfs,\
 vpksf,vpksg,vpksh,vmaeb,veslh,vmaef,vpklsf,vpklsg,vpklsh,verllb,vchb,verllf,\
-verllg,verllh,wfsdb,maeb,vclgdb,vftcidb,vpksgs,vmxf,vmxg,vmxh,fidbra,vm

[S/390] Re: [PATCH 1/2] zEC12 pipeline

2018-09-06 Thread Robin Dapp
Sorry, forgot the [S/390] tag in the subject.



Re: [PATCH] Backport gettext fixes to get rid of warnings on macOS

2018-09-06 Thread Simon Marchi
On 2018-08-01 03:58 PM, Simon Marchi wrote:
> This patch was tested to build binutils-gdb on GNU/Linux and macOS.  It can be
> applied to the gcc repo too, after fixing some trivial merge conflicts 
> (someone
> else will need to do it, as I don't have push access to gcc).  Although I 
> think
> it is relatively low-risk, building gcc on macOS was not tested with this
> patch, so if somebody that has already a macOS build can do it, it would be
> appreciated.
> 
> Two fixes were committed recently to the gettext repo in order to make
> gdb build warning-free on macOS.  This patch backports them both:
> 
>   - Make the format_arg attribute effective also in the case 
> _INTL_REDIRECT_INLINE.
> 113893dce80358a4ae0d9463ce73c5670c81cf0c
> 
> http://git.savannah.gnu.org/cgit/gettext.git/commit/?id=113893dce80358a4ae0d9463ce73c5670c81cf0c
> 
>   - Enable the format_arg attribute also on clang on Mac OS X.
> bd6a52241c7c83c90e043ace2082a2508d273f55
> 
> http://git.savannah.gnu.org/cgit/gettext.git/commit/?id=bd6a52241c7c83c90e043ace2082a2508d273f55
> 
> intl/ChangeLog:
> 
>   * libgnuintl.h (_INTL_MAY_RETURN_STRING_ARG, gettext, dgettext,
>   dcgettext, ngettext, dngettext, dcngettext): Backport changes
>   from upstream gettext.
> ---
>  intl/libgnuintl.h | 35 +++
>  1 file changed, 23 insertions(+), 12 deletions(-)
> 
> diff --git a/intl/libgnuintl.h b/intl/libgnuintl.h
> index acc9093..7616d6f 100644
> --- a/intl/libgnuintl.h
> +++ b/intl/libgnuintl.h
> @@ -115,7 +115,7 @@ extern "C" {
>  /* _INTL_MAY_RETURN_STRING_ARG(n) declares that the given function may return
> its n-th argument literally.  This enables GCC to warn for example about
> printf (gettext ("foo %y")).  */
> -#if __GNUC__ >= 3 && !(__APPLE_CC__ > 1 && defined __cplusplus)
> +#if defined __GNUC__ && __GNUC__ >= 3 && !(defined __APPLE_CC__ && 
> __APPLE_CC__ > 1 && !(defined __clang__ && __clang__ && __clang_major__ >= 3) 
> && defined __cplusplus)
>  # define _INTL_MAY_RETURN_STRING_ARG(n) __attribute__ ((__format_arg__ (n)))
>  #else
>  # define _INTL_MAY_RETURN_STRING_ARG(n)
> @@ -127,7 +127,9 @@ extern "C" {
>  #ifdef _INTL_REDIRECT_INLINE
>  extern char *libintl_gettext (const char *__msgid)
> _INTL_MAY_RETURN_STRING_ARG (1);
> -static inline char *gettext (const char *__msgid)
> +static inline
> +_INTL_MAY_RETURN_STRING_ARG (1)
> +char *gettext (const char *__msgid)
>  {
>return libintl_gettext (__msgid);
>  }
> @@ -145,7 +147,9 @@ extern char *gettext _INTL_PARAMS ((const char *__msgid))
>  #ifdef _INTL_REDIRECT_INLINE
>  extern char *libintl_dgettext (const char *__domainname, const char *__msgid)
> _INTL_MAY_RETURN_STRING_ARG (2);
> -static inline char *dgettext (const char *__domainname, const char *__msgid)
> +static inline
> +_INTL_MAY_RETURN_STRING_ARG (2)
> +char *dgettext (const char *__domainname, const char *__msgid)
>  {
>return libintl_dgettext (__domainname, __msgid);
>  }
> @@ -165,8 +169,9 @@ extern char *dgettext _INTL_PARAMS ((const char 
> *__domainname,
>  extern char *libintl_dcgettext (const char *__domainname, const char 
> *__msgid,
>   int __category)
> _INTL_MAY_RETURN_STRING_ARG (2);
> -static inline char *dcgettext (const char *__domainname, const char *__msgid,
> -int __category)
> +static inline
> +_INTL_MAY_RETURN_STRING_ARG (2)
> +char *dcgettext (const char *__domainname, const char *__msgid, int 
> __category)
>  {
>return libintl_dcgettext (__domainname, __msgid, __category);
>  }
> @@ -188,8 +193,10 @@ extern char *dcgettext _INTL_PARAMS ((const char 
> *__domainname,
>  extern char *libintl_ngettext (const char *__msgid1, const char *__msgid2,
>  unsigned long int __n)
> _INTL_MAY_RETURN_STRING_ARG (1) _INTL_MAY_RETURN_STRING_ARG (2);
> -static inline char *ngettext (const char *__msgid1, const char *__msgid2,
> -   unsigned long int __n)
> +static inline
> +_INTL_MAY_RETURN_STRING_ARG (1) _INTL_MAY_RETURN_STRING_ARG (2)
> +char *ngettext (const char *__msgid1, const char *__msgid2,
> + unsigned long int __n)
>  {
>return libintl_ngettext (__msgid1, __msgid2, __n);
>  }
> @@ -210,8 +217,10 @@ extern char *ngettext _INTL_PARAMS ((const char 
> *__msgid1,
>  extern char *libintl_dngettext (const char *__domainname, const char 
> *__msgid1,
>   const char *__msgid2, unsigned long int __n)
> _INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3);
> -static inline char *dngettext (const char *__domainname, const char 
> *__msgid1,
> -const char *__msgid2, unsigned long int __n)
> +static inline
> +_INTL_MAY_RETURN_STRING_ARG (2) _INTL_MAY_RETURN_STRING_ARG (3)
> +char *dngettext (const char *__domainname, const char *__msgid1,
> +  const char *__msgid2, unsigned long int __n)
>  {
>return 

Re: [PATCH] Use complete_array_type on flexible array member initializers

2018-09-06 Thread Bernd Edlinger
On 09/04/18 16:30, Jeff Law wrote:
> On 09/03/2018 06:35 AM, Bernd Edlinger wrote:
> [ Big snip, dropping lots of context ]
> 
>

 No I don't think so, because at that time BRACE_ENCLOSED_INITIALIZER_P
 property does no longer work, as I explained in the previous mail.

 And cp_complete_array_type does use that property:
>>> [ ... ]
>>> Jason's the expert here.I'll defer to his expertise.  It just seemed
>>> a bit odd to me that we have a routine to "complete" an array that does
>>> any special C++ handling (cp_complete_array_type) and we're not using it.
>>>
>>
>> Agreed, I have posted an update which uses cp_complete_array_type, since
>> Jason raised the same point.
>>
>> But since C++ does not need the recursion here, things are a lot more easy.
>> The patch still completes the array type _after_ the FE is completely done 
>> with the
>> parsing, since I want to avoid to destroy the information too early, since 
>> the FE is looking
>> at the TYPE_DOMAIN==NULL at various places.
> FYI, I don't see a follow-up for this patch?  Did I miss it?  Or is it
> under a different subject line?
> 
> jeff
> 

Yes, thanks for reminding me.
I had forgotten to post the updated patch.

So here is my latest version of the flexible array patch.

Bootstrapped and reg-tested on x86_64-pc-linux-gnu (together with the other 
STRING_CST-v2 patches).
Is it OK for trunk?


Thanks
Bernd.
gcc:
2018-08-30  Bernd Edlinger  

	* varasm.c (output_constructor_regular_field): Check TYPE_SIZE_UNIT of
	the init value.

c-family:
2018-08-30  Bernd Edlinger  

	* c-common.c (complete_flexible_array_elts): New helper function.
	* c-common.h (complete_flexible_array_elts): Declare.

c:
2018-08-30  Bernd Edlinger  

	* c-decl.c (finish_decl): Call complete_flexible_array_elts.

cp:
2018-08-30  Bernd Edlinger  

	* decl.c (check_initializer): Call complete_flexible_array_elts.


diff -Npur gcc/c/c-decl.c gcc/c/c-decl.c
--- gcc/c/c-decl.c	2018-08-21 08:17:41.0 +0200
+++ gcc/c/c-decl.c	2018-08-24 12:06:21.374892294 +0200
@@ -5035,6 +5035,8 @@ finish_decl (tree decl, location_t init_
   if (init && TREE_CODE (init) == CONSTRUCTOR)
 	add_flexible_array_elts_to_size (decl, init);
 
+  complete_flexible_array_elts (DECL_INITIAL (decl));
+
   if (DECL_SIZE (decl) == NULL_TREE && TREE_TYPE (decl) != error_mark_node
 	  && COMPLETE_TYPE_P (TREE_TYPE (decl)))
 	layout_decl (decl, 0);
diff -Npur gcc/c-family/c-common.c gcc/c-family/c-common.c
--- gcc/c-family/c-common.c	2018-08-17 05:02:11.0 +0200
+++ gcc/c-family/c-common.c	2018-08-24 12:45:56.559011703 +0200
@@ -6427,6 +6427,28 @@ complete_array_type (tree *ptype, tree i
   return failure;
 }
 
+/* INIT is an constructor of a structure with a flexible array member.
+   Complete the flexible array member with a domain based on it's value.  */
+void
+complete_flexible_array_elts (tree init)
+{
+  tree elt, type;
+
+  if (init == NULL_TREE || TREE_CODE (init) != CONSTRUCTOR)
+return;
+
+  if (vec_safe_is_empty (CONSTRUCTOR_ELTS (init)))
+return;
+
+  elt = CONSTRUCTOR_ELTS (init)->last ().value;
+  type = TREE_TYPE (elt);
+  if (TREE_CODE (type) == ARRAY_TYPE
+  && TYPE_SIZE (type) == NULL_TREE)
+complete_array_type (&TREE_TYPE (elt), elt, false);
+  else
+complete_flexible_array_elts (elt);
+}
+
 /* Like c_mark_addressable but don't check register qualifier.  */
 void 
 c_common_mark_addressable_vec (tree t)
diff -Npur gcc/c-family/c-common.h gcc/c-family/c-common.h
--- gcc/c-family/c-common.h	2018-08-17 05:02:11.0 +0200
+++ gcc/c-family/c-common.h	2018-08-24 12:06:21.375892280 +0200
@@ -1038,6 +1038,7 @@ extern tree fold_offsetof (tree, tree =
 			   tree_code ctx = ERROR_MARK);
 
 extern int complete_array_type (tree *, tree, bool);
+extern void complete_flexible_array_elts (tree);
 
 extern tree builtin_type_for_size (int, bool);
 
diff -Npur gcc/cp/decl.c gcc/cp/decl.c
--- gcc/cp/decl.c	2018-08-22 22:35:38.0 +0200
+++ gcc/cp/decl.c	2018-08-30 12:06:21.377892252 +0200
@@ -6530,6 +6530,16 @@ check_initializer (tree decl, tree init,
 
 	  init_code = store_init_value (decl, init, cleanups, flags);
 
+	  if (DECL_INITIAL (decl)
+	  && TREE_CODE (DECL_INITIAL (decl)) == CONSTRUCTOR
+	  && !vec_safe_is_empty (CONSTRUCTOR_ELTS (DECL_INITIAL (decl
+	{
+	  tree elt = CONSTRUCTOR_ELTS (DECL_INITIAL (decl))->last ().value;
+	  if (TREE_CODE (TREE_TYPE (elt)) == ARRAY_TYPE
+		  && TYPE_SIZE (TREE_TYPE (elt)) == NULL_TREE)
+		cp_complete_array_type (&TREE_TYPE (elt), elt, false);
+	}
+
 	  if (pedantic && TREE_CODE (type) == ARRAY_TYPE
 	  && DECL_INITIAL (decl)
 	  && TREE_CODE (DECL_INITIAL (decl)) == STRING_CST
diff -Npur gcc/varasm.c gcc/varasm.c
--- gcc/varasm.c	2018-08-16 17:28:11.0 +0200
+++ gcc/varasm.c	2018-08-24 12:06:21.378892238 +0200
@@ -5161,6 +5161,8 @@ output_constructor_regular_field (oc_loc
 	 on the chain is a TYPE_DECL of the enclosing struct.  */
 	  cons

[PATCH v4 04/10] testsuite: Add check for overflowed IMEM region to testsuite

2018-09-06 Thread Dimitar Dimitrov
PRU architecture supports maximum 256k program memory (IMEM). Some GCC
test cases manage to produce executables bigger than that.

gcc/testsuite/ChangeLog:

2018-08-29  Dimitar Dimitrov  

* lib/gcc-dg.exp: Bail on region overflow for tiny targets.
* lib/target-utils.exp: Ditto.
* lib/target-supports.exp: Declare PRU target as tiny.

Signed-off-by: Dimitar Dimitrov 
---
 gcc/testsuite/lib/gcc-dg.exp  | 5 +
 gcc/testsuite/lib/target-supports.exp | 5 +
 gcc/testsuite/lib/target-utils.exp| 4 
 3 files changed, 14 insertions(+)

diff --git a/gcc/testsuite/lib/gcc-dg.exp b/gcc/testsuite/lib/gcc-dg.exp
index 24d0b00d25d..7ef9de59dc2 100644
--- a/gcc/testsuite/lib/gcc-dg.exp
+++ b/gcc/testsuite/lib/gcc-dg.exp
@@ -394,6 +394,11 @@ proc gcc-dg-prune { system text } {
 return "::unsupported::memory full"
 }
 
+if { [regexp "(^|\n)\[^\n\]*: region \[^\n\]* overflowed" $text] 
+  && [check_effective_target_tiny] } {
+   return "::unsupported::memory full"
+}
+
 # Likewise, if we see ".text exceeds local store range" or
 # similar.
 if {[string match "spu-*" $system] && \
diff --git a/gcc/testsuite/lib/target-supports.exp 
b/gcc/testsuite/lib/target-supports.exp
index ce89f618349..7d4ea35babb 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -8843,6 +8843,11 @@ proc check_effective_target_tiny {} {
  && [check_effective_target_avr_tiny] } {
  set et_target_tiny_saved 1
}
+   # PRU Program Counter is 16-bits, and trampolines are not supported.
+   # Hence directly declare as a tiny target.
+   if [istarget pru-*-*] {
+ set et_target_tiny_saved 1
+   }
 }
 
 return $et_target_tiny_saved
diff --git a/gcc/testsuite/lib/target-utils.exp 
b/gcc/testsuite/lib/target-utils.exp
index bd39cc5bc79..732a1827a02 100644
--- a/gcc/testsuite/lib/target-utils.exp
+++ b/gcc/testsuite/lib/target-utils.exp
@@ -35,6 +35,10 @@ proc ${tool}_check_unsupported_p { output } {
   && [check_effective_target_tiny] } {
 return "memory full"
  }
+if { [regexp "(^|\n)\[^\n\]*: region \[^\n\]* overflowed" $output]
+  && [check_effective_target_tiny] } {
+   return "memory full"
+}
 
 if { [istarget spu-*-*] && \
 [string match "*exceeds local store*" $output] } {
-- 
2.11.0



[PATCH v4 00/10] New backend for the TI PRU processor

2018-09-06 Thread Dimitar Dimitrov
This patch series adds support for the TI PRU I/O processor to GCC. This
fourth patch set revision addresses comments from v1 [1], v2 [2] and
v3 [3].

Test results can be downloaded from here:
   http://dinux.eu/gnupru/testresults/20180828-f4455d5f/

Changes since patch series v3 [3]:
  - Added blockage in epilogue before SP restore.
  - Folded "mov" patterns.

[1] http://gcc.gnu.org/ml/gcc-patches/2018-06/msg00775.html
[2] http://gcc.gnu.org/ml/gcc-patches/2018-07/msg01779.html
[3] http://gcc.gnu.org/ml/gcc-patches/2018-08/msg00927.html

Dimitar Dimitrov (10):
  Initial TI PRU GCC port
  Initial TI PRU libgcc port
  testsuite: Add PRU tests
  testsuite: Add check for overflowed IMEM region to testsuite
  testsuite: Add check for unsupported TI ABI PRU features to testsuite
  testsuite: Remove PRU from test cases requiring hosted environment
  testsuite: Define PRU stack usage
  testsuite: Mark that PRU has one-cycle jumps
  testsuite: Mark that PRU uses all function pointer bits
  testsuite: Mark testsuite that PRU has different calling convention

 configure.ac   |7 +
 gcc/common/config/pru/pru-common.c |   36 +
 gcc/config.gcc |9 +
 gcc/config/pru/alu-zext.md |  178 ++
 gcc/config/pru/constraints.md  |   88 +
 gcc/config/pru/predicates.md   |  224 ++
 gcc/config/pru/pru-opts.h  |   31 +
 gcc/config/pru/pru-passes.c|  234 ++
 gcc/config/pru/pru-pragma.c|   90 +
 gcc/config/pru/pru-protos.h|   72 +
 gcc/config/pru/pru.c   | 3008 
 gcc/config/pru/pru.h   |  551 
 gcc/config/pru/pru.md  |  946 ++
 gcc/config/pru/pru.opt |   53 +
 gcc/config/pru/t-pru   |   31 +
 gcc/doc/extend.texi|   21 +
 gcc/doc/invoke.texi|   55 +
 gcc/doc/md.texi|   22 +
 gcc/testsuite/g++.old-deja/g++.abi/ptrmem.C|2 +-
 gcc/testsuite/gcc.c-torture/execute/20101011-1.c   |3 +
 gcc/testsuite/gcc.dg/20020312-2.c  |2 +
 gcc/testsuite/gcc.dg/builtin-apply2.c  |2 +-
 gcc/testsuite/gcc.dg/stack-usage-1.c   |2 +
 .../gcc.dg/torture/stackalign/builtin-apply-2.c|2 +-
 gcc/testsuite/gcc.dg/tree-ssa/20040204-1.c |2 +-
 gcc/testsuite/gcc.dg/tree-ssa/reassoc-33.c |2 +-
 gcc/testsuite/gcc.dg/tree-ssa/reassoc-34.c |2 +-
 gcc/testsuite/gcc.dg/tree-ssa/reassoc-35.c |2 +-
 gcc/testsuite/gcc.dg/tree-ssa/reassoc-36.c |2 +-
 gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-14.c  |2 +-
 gcc/testsuite/gcc.target/pru/abi-arg-struct.c  |  164 ++
 gcc/testsuite/gcc.target/pru/ashiftrt.c|   13 +
 gcc/testsuite/gcc.target/pru/builtins-1.c  |   12 +
 gcc/testsuite/gcc.target/pru/builtins-error.c  |6 +
 gcc/testsuite/gcc.target/pru/clearbit.c|   13 +
 gcc/testsuite/gcc.target/pru/loop-asm.c|   19 +
 gcc/testsuite/gcc.target/pru/loop-dowhile.c|   45 +
 gcc/testsuite/gcc.target/pru/loop-hi-1.c   |   38 +
 gcc/testsuite/gcc.target/pru/loop-hi-2.c   |   17 +
 gcc/testsuite/gcc.target/pru/loop-qi-1.c   |   38 +
 gcc/testsuite/gcc.target/pru/loop-qi-2.c   |   17 +
 gcc/testsuite/gcc.target/pru/loop-short-1.c|   53 +
 gcc/testsuite/gcc.target/pru/loop-short-2.c|   21 +
 gcc/testsuite/gcc.target/pru/loop-si-1.c   |   41 +
 gcc/testsuite/gcc.target/pru/loop-si-2.c   |   20 +
 .../gcc.target/pru/loop-u8_pcrel_overflow.c|   42 +
 gcc/testsuite/gcc.target/pru/loop-ubyte-1.c|   30 +
 gcc/testsuite/gcc.target/pru/loop-ubyte-2.c|   18 +
 .../pru/lra-framepointer-fragmentation-1.c |   33 +
 .../pru/lra-framepointer-fragmentation-2.c |   61 +
 gcc/testsuite/gcc.target/pru/mabi-ti-1.c   |   10 +
 gcc/testsuite/gcc.target/pru/mabi-ti-2.c   |   15 +
 gcc/testsuite/gcc.target/pru/mabi-ti-3.c   |   12 +
 gcc/testsuite/gcc.target/pru/mabi-ti-4.c   |   14 +
 gcc/testsuite/gcc.target/pru/mabi-ti-5.c   |   33 +
 gcc/testsuite/gcc.target/pru/mabi-ti-6.c   |   12 +
 gcc/testsuite/gcc.target/pru/mabi-ti-7.c   |   21 +
 gcc/testsuite/gcc.target/pru/pr64366.c |  128 +
 gcc/testsuite/gcc.target/pru/pragma-ctable_entry.c |   22 +
 gcc/testsuite/gcc.target/pru/pru.exp   |   41 +
 gcc/testsuite/gcc.target/pru/qbbc-1.c  |   29 +
 gcc/testsuite/gcc.target/pru/qbbc-2.c  |   15 +
 gcc/testsuite/gcc.target/pru/qbbc-3.c  |   15 +
 gcc/testsuite/gcc.target/pru/qbbs-1.c

[PATCH v4 03/10] testsuite: Add PRU tests

2018-09-06 Thread Dimitar Dimitrov
gcc/testsuite/ChangeLog:

2018-08-29  Dimitar Dimitrov  

* gcc.target/pru/abi-arg-struct.c: New test.
* gcc.target/pru/ashiftrt.c: New test.
* gcc.target/pru/builtins-1.c: New test.
* gcc.target/pru/builtins-error.c: New test.
* gcc.target/pru/clearbit.c: New test.
* gcc.target/pru/loop-asm.c: New test.
* gcc.target/pru/loop-dowhile.c: New test.
* gcc.target/pru/loop-hi-1.c: New test.
* gcc.target/pru/loop-hi-2.c: New test.
* gcc.target/pru/loop-qi-1.c: New test.
* gcc.target/pru/loop-qi-2.c: New test.
* gcc.target/pru/loop-short-1.c: New test.
* gcc.target/pru/loop-short-2.c: New test.
* gcc.target/pru/loop-si-1.c: New test.
* gcc.target/pru/loop-si-2.c: New test.
* gcc.target/pru/loop-u8_pcrel_overflow.c: New test.
* gcc.target/pru/loop-ubyte-1.c: New test.
* gcc.target/pru/loop-ubyte-2.c: New test.
* gcc.target/pru/lra-framepointer-fragmentation-1.c: New test.
* gcc.target/pru/lra-framepointer-fragmentation-2.c: New test.
* gcc.target/pru/mabi-ti-1.c: New test.
* gcc.target/pru/mabi-ti-2.c: New test.
* gcc.target/pru/mabi-ti-3.c: New test.
* gcc.target/pru/mabi-ti-4.c: New test.
* gcc.target/pru/mabi-ti-5.c: New test.
* gcc.target/pru/mabi-ti-6.c: New test.
* gcc.target/pru/mabi-ti-7.c: New test.
* gcc.target/pru/pr64366.c: New test.
* gcc.target/pru/pragma-ctable_entry.c: New test.
* gcc.target/pru/pru.exp: New file.
* gcc.target/pru/qbbc-1.c: New test.
* gcc.target/pru/qbbc-2.c: New test.
* gcc.target/pru/qbbc-3.c: New test.
* gcc.target/pru/qbbs-1.c: New test.
* gcc.target/pru/qbbs-2.c: New test.
* gcc.target/pru/setbit.c: New test.
* gcc.target/pru/zero_extend-and-hisi.c: New test.
* gcc.target/pru/zero_extend-and-qihi.c: New test.
* gcc.target/pru/zero_extend-and-qisi.c: New test.
* gcc.target/pru/zero_extend-hisi.c: New test.
* gcc.target/pru/zero_extend-qihi.c: New test.
* gcc.target/pru/zero_extend-qisi.c: New test.
* lib/target-supports.exp: Add PRU to feature filters.

Signed-off-by: Dimitar Dimitrov 
---
 gcc/testsuite/gcc.target/pru/abi-arg-struct.c  | 164 +
 gcc/testsuite/gcc.target/pru/ashiftrt.c|  13 ++
 gcc/testsuite/gcc.target/pru/builtins-1.c  |  12 ++
 gcc/testsuite/gcc.target/pru/builtins-error.c  |   6 +
 gcc/testsuite/gcc.target/pru/clearbit.c|  13 ++
 gcc/testsuite/gcc.target/pru/loop-asm.c|  19 +++
 gcc/testsuite/gcc.target/pru/loop-dowhile.c|  45 ++
 gcc/testsuite/gcc.target/pru/loop-hi-1.c   |  38 +
 gcc/testsuite/gcc.target/pru/loop-hi-2.c   |  17 +++
 gcc/testsuite/gcc.target/pru/loop-qi-1.c   |  38 +
 gcc/testsuite/gcc.target/pru/loop-qi-2.c   |  17 +++
 gcc/testsuite/gcc.target/pru/loop-short-1.c|  53 +++
 gcc/testsuite/gcc.target/pru/loop-short-2.c|  21 +++
 gcc/testsuite/gcc.target/pru/loop-si-1.c   |  41 ++
 gcc/testsuite/gcc.target/pru/loop-si-2.c   |  20 +++
 .../gcc.target/pru/loop-u8_pcrel_overflow.c|  42 ++
 gcc/testsuite/gcc.target/pru/loop-ubyte-1.c|  30 
 gcc/testsuite/gcc.target/pru/loop-ubyte-2.c|  18 +++
 .../pru/lra-framepointer-fragmentation-1.c |  33 +
 .../pru/lra-framepointer-fragmentation-2.c |  61 
 gcc/testsuite/gcc.target/pru/mabi-ti-1.c   |  10 ++
 gcc/testsuite/gcc.target/pru/mabi-ti-2.c   |  15 ++
 gcc/testsuite/gcc.target/pru/mabi-ti-3.c   |  12 ++
 gcc/testsuite/gcc.target/pru/mabi-ti-4.c   |  14 ++
 gcc/testsuite/gcc.target/pru/mabi-ti-5.c   |  33 +
 gcc/testsuite/gcc.target/pru/mabi-ti-6.c   |  12 ++
 gcc/testsuite/gcc.target/pru/mabi-ti-7.c   |  21 +++
 gcc/testsuite/gcc.target/pru/pr64366.c | 128 
 gcc/testsuite/gcc.target/pru/pragma-ctable_entry.c |  22 +++
 gcc/testsuite/gcc.target/pru/pru.exp   |  41 ++
 gcc/testsuite/gcc.target/pru/qbbc-1.c  |  29 
 gcc/testsuite/gcc.target/pru/qbbc-2.c  |  15 ++
 gcc/testsuite/gcc.target/pru/qbbc-3.c  |  15 ++
 gcc/testsuite/gcc.target/pru/qbbs-1.c  |  29 
 gcc/testsuite/gcc.target/pru/qbbs-2.c  |  15 ++
 gcc/testsuite/gcc.target/pru/setbit.c  |  13 ++
 .../gcc.target/pru/zero_extend-and-hisi.c  |  16 ++
 .../gcc.target/pru/zero_extend-and-qihi.c  |  16 ++
 .../gcc.target/pru/zero_extend-and-qisi.c  |  16 ++
 gcc/testsuite/gcc.target/pru/zero_extend-hisi.c|  43 ++
 gcc/testsuite/gcc.target/pru/zero_extend-qihi.c|  43 ++
 gcc/testsuite/gcc.target/pru/zero_extend-qisi.c|  43 ++
 gcc/testsuite/lib/target-supports.exp 

[PATCH v4 02/10] Initial TI PRU libgcc port

2018-09-06 Thread Dimitar Dimitrov
The floating point support has been borrowed from C6X libgcc port
to help with TI PRU toolchain ABI compatibility.

libgcc/ChangeLog:

2018-08-29  Dimitar Dimitrov  

* config.host: Add PRU target.
* config/pru/asri.c: New file.
* config/pru/eqd.c: New file.
* config/pru/eqf.c: New file.
* config/pru/ged.c: New file.
* config/pru/gef.c: New file.
* config/pru/gtd.c: New file.
* config/pru/gtf.c: New file.
* config/pru/led.c: New file.
* config/pru/lef.c: New file.
* config/pru/lib2bitcountHI.c: New file.
* config/pru/lib2divHI.c: New file.
* config/pru/lib2divQI.c: New file.
* config/pru/lib2divSI.c: New file.
* config/pru/libgcc-eabi.ver: New file.
* config/pru/ltd.c: New file.
* config/pru/ltf.c: New file.
* config/pru/mpyll.S: New file.
* config/pru/pru-abi.h: New file.
* config/pru/pru-asm.h: New file.
* config/pru/pru-divmod.h: New file.
* config/pru/sfp-machine.h: New file.
* config/pru/t-pru: New file.

Signed-off-by: Dimitar Dimitrov 
---
 libgcc/config.host |   7 +++
 libgcc/config/pru/asri.c   |  33 ++
 libgcc/config/pru/eqd.c|  45 +
 libgcc/config/pru/eqf.c|  45 +
 libgcc/config/pru/ged.c|  45 +
 libgcc/config/pru/gef.c|  45 +
 libgcc/config/pru/gtd.c|  45 +
 libgcc/config/pru/gtf.c|  45 +
 libgcc/config/pru/led.c|  45 +
 libgcc/config/pru/lef.c|  45 +
 libgcc/config/pru/lib2bitcountHI.c |  43 +
 libgcc/config/pru/lib2divHI.c  |  42 +
 libgcc/config/pru/lib2divQI.c  |  42 +
 libgcc/config/pru/lib2divSI.c  |  48 ++
 libgcc/config/pru/libgcc-eabi.ver  |  88 ++
 libgcc/config/pru/ltd.c|  45 +
 libgcc/config/pru/ltf.c|  45 +
 libgcc/config/pru/mpyll.S  |  57 +
 libgcc/config/pru/pru-abi.h| 109 
 libgcc/config/pru/pru-asm.h|  35 +++
 libgcc/config/pru/pru-divmod.h | 117 ++
 libgcc/config/pru/sfp-machine.h| 125 +
 libgcc/config/pru/t-pru|  50 +++
 23 files changed, 1246 insertions(+)
 create mode 100644 libgcc/config/pru/asri.c
 create mode 100644 libgcc/config/pru/eqd.c
 create mode 100644 libgcc/config/pru/eqf.c
 create mode 100644 libgcc/config/pru/ged.c
 create mode 100644 libgcc/config/pru/gef.c
 create mode 100644 libgcc/config/pru/gtd.c
 create mode 100644 libgcc/config/pru/gtf.c
 create mode 100644 libgcc/config/pru/led.c
 create mode 100644 libgcc/config/pru/lef.c
 create mode 100644 libgcc/config/pru/lib2bitcountHI.c
 create mode 100644 libgcc/config/pru/lib2divHI.c
 create mode 100644 libgcc/config/pru/lib2divQI.c
 create mode 100644 libgcc/config/pru/lib2divSI.c
 create mode 100644 libgcc/config/pru/libgcc-eabi.ver
 create mode 100644 libgcc/config/pru/ltd.c
 create mode 100644 libgcc/config/pru/ltf.c
 create mode 100644 libgcc/config/pru/mpyll.S
 create mode 100644 libgcc/config/pru/pru-abi.h
 create mode 100644 libgcc/config/pru/pru-asm.h
 create mode 100644 libgcc/config/pru/pru-divmod.h
 create mode 100644 libgcc/config/pru/sfp-machine.h
 create mode 100644 libgcc/config/pru/t-pru

diff --git a/libgcc/config.host b/libgcc/config.host
index 029f6569caf..5206b5dc9d7 100644
--- a/libgcc/config.host
+++ b/libgcc/config.host
@@ -168,6 +168,9 @@ nios2*-*-*)
 powerpc*-*-*)
cpu_type=rs6000
;;
+pru-*-*)
+   cpu_type=pru
+   ;;
 rs6000*-*-*)
;;
 riscv*-*-*)
@@ -1158,6 +1161,10 @@ powerpcle-*-eabi*)
tmake_file="${tmake_file} rs6000/t-ppccomm rs6000/t-crtstuff 
t-crtstuff-pic t-fdpbit"
extra_parts="$extra_parts crtbegin.o crtend.o crtbeginS.o crtendS.o 
crtbeginT.o ecrti.o ecrtn.o ncrti.o ncrtn.o"
;;
+pru-*-*)
+   tmake_file="${tmake_file} t-softfp-sfdf t-softfp-excl t-softfp 
t-gnu-prefix pru/t-pru"
+   tm_file="$tm_file pru/pru-abi.h"
+   ;;
 riscv*-*-linux*)
tmake_file="${tmake_file} riscv/t-softfp${host_address} t-softfp 
riscv/t-elf riscv/t-elf${host_address}"
extra_parts="$extra_parts crtbegin.o crtend.o crti.o crtn.o crtendS.o 
crtbeginT.o"
diff --git a/libgcc/config/pru/asri.c b/libgcc/config/pru/asri.c
new file mode 100644
index 000..591d660f227
--- /dev/null
+++ b/libgcc/config/pru/asri.c
@@ -0,0 +1,33 @@
+/* PRU ABI compatibility functions
+   Arithmetic right shift
+   Copyright (C) 2017-2018 Free Software Foundation, Inc.
+   Contributed by Dimitar Dimitrov 
+
+   This file is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   

[PATCH v4 06/10] testsuite: Remove PRU from test cases requiring hosted environment

2018-09-06 Thread Dimitar Dimitrov
gcc/testsuite/ChangeLog:

2018-08-29  Dimitar Dimitrov  

* gcc.c-torture/execute/20101011-1.c: Define DO_TEST to 0 for PRU.
* gcc.dg/20020312-2.c: No PIC register for PRU.

Signed-off-by: Dimitar Dimitrov 
---
 gcc/testsuite/gcc.c-torture/execute/20101011-1.c | 3 +++
 gcc/testsuite/gcc.dg/20020312-2.c| 2 ++
 2 files changed, 5 insertions(+)

diff --git a/gcc/testsuite/gcc.c-torture/execute/20101011-1.c 
b/gcc/testsuite/gcc.c-torture/execute/20101011-1.c
index f95d900deaf..aa72b35fa16 100644
--- a/gcc/testsuite/gcc.c-torture/execute/20101011-1.c
+++ b/gcc/testsuite/gcc.c-torture/execute/20101011-1.c
@@ -97,6 +97,9 @@ __aeabi_idiv0 (int return_value)
   /* This presently doesn't raise SIGFPE even on csky-linux-gnu, much
  less bare metal.  See the implementation of __divsi3 in libgcc.  */
 # define DO_TEST 0
+#elif defined (__pru__)
+/* There isn't even a signal function.  */
+# define DO_TEST 0
 #else
 # define DO_TEST 1
 #endif
diff --git a/gcc/testsuite/gcc.dg/20020312-2.c 
b/gcc/testsuite/gcc.dg/20020312-2.c
index f8be3ce2964..365ae6e847c 100644
--- a/gcc/testsuite/gcc.dg/20020312-2.c
+++ b/gcc/testsuite/gcc.dg/20020312-2.c
@@ -116,6 +116,8 @@ extern void abort (void);
 # if defined (__CK807__) || defined (__CK810__)
 #   define PIC_REG  "r28"
 # endif
+#elif defined(__PRU__)
+/* No pic register.  */
 #else
 # error "Modify the test for your target."
 #endif
-- 
2.11.0



[PATCH v4 07/10] testsuite: Define PRU stack usage

2018-09-06 Thread Dimitar Dimitrov
gcc/testsuite/ChangeLog:

2018-08-29  Dimitar Dimitrov  

* gcc.dg/stack-usage-1.c: Define PRU stack usage.

Signed-off-by: Dimitar Dimitrov 
---
 gcc/testsuite/gcc.dg/stack-usage-1.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/gcc/testsuite/gcc.dg/stack-usage-1.c 
b/gcc/testsuite/gcc.dg/stack-usage-1.c
index e6440142e1d..b2642228808 100644
--- a/gcc/testsuite/gcc.dg/stack-usage-1.c
+++ b/gcc/testsuite/gcc.dg/stack-usage-1.c
@@ -93,6 +93,8 @@
 #  define SIZE 254
 #elif defined (__nios2__)
 #  define SIZE 252
+#elif defined (__PRU__)
+#  define SIZE 252
 #elif defined (__v850__)
 #define SIZE 260
 #elif defined (__mn10300__)
-- 
2.11.0



[PATCH v4 05/10] testsuite: Add check for unsupported TI ABI PRU features to testsuite

2018-09-06 Thread Dimitar Dimitrov
Not all C language features are supported when -mabi=ti option is
used for PRU target.

gcc/testsuite/ChangeLog:

2018-08-29  Dimitar Dimitrov  

* lib/gcc-dg.exp: Filter unsupported features in PRU's TI ABI mode.
* lib/target-utils.exp: Ditto.
* lib/target-supports.exp (check_effective_target_function_pointers,
check_effective_target_large_return_values): New.

Signed-off-by: Dimitar Dimitrov 
---
 gcc/testsuite/lib/gcc-dg.exp  | 11 +++
 gcc/testsuite/lib/target-supports.exp | 26 ++
 gcc/testsuite/lib/target-utils.exp|  8 
 3 files changed, 45 insertions(+)

diff --git a/gcc/testsuite/lib/gcc-dg.exp b/gcc/testsuite/lib/gcc-dg.exp
index 7ef9de59dc2..8f70232914b 100644
--- a/gcc/testsuite/lib/gcc-dg.exp
+++ b/gcc/testsuite/lib/gcc-dg.exp
@@ -407,6 +407,17 @@ proc gcc-dg-prune { system text } {
return "::unsupported::memory full"
 }
 
+if { [string match "*error: function pointers not supported*" $text]
+ && ![check_effective_target_function_pointers] } {
+   # The format here is important.  See dg.exp.
+   return "::unsupported::funcptr"
+}
+if { [string match "*error: large return values not supported*" $text]
+ && ![check_effective_target_large_return_values] } {
+   # The format here is important.  See dg.exp.
+   return "::unsupported::large return values"
+}
+
 return $text
 }
 
diff --git a/gcc/testsuite/lib/target-supports.exp 
b/gcc/testsuite/lib/target-supports.exp
index 7d4ea35babb..08c011317b4 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -2619,6 +2619,32 @@ proc check_effective_target_ptr32plus { } {
 }]
 }
 
+# Return 1 if target supports function pointers, 0 otherwise.
+
+proc check_effective_target_function_pointers { } {
+if { [istarget pru-*-*] } {
+   return [check_no_compiler_messages func_ptr_avail assembly {
+   #ifdef __PRU_EABI_GNU__
+   #error unsupported
+   #endif
+   }]
+}
+return 1
+}
+
+# Return 1 if target supports arbitrarily large return values, 0 otherwise.
+
+proc check_effective_target_large_return_values { } {
+if { [istarget pru-*-*] } {
+   return [check_no_compiler_messages func_ptr_avail assembly {
+   #ifdef __PRU_EABI_GNU__
+   #error unsupported
+   #endif
+   }]
+}
+return 1
+}
+
 # Return 1 if we support 32-bit or larger array and structure sizes
 # using default options, 0 otherwise.  Avoid false positive on
 # targets with 20 or 24 bit address spaces.
diff --git a/gcc/testsuite/lib/target-utils.exp 
b/gcc/testsuite/lib/target-utils.exp
index 732a1827a02..f636be2cb01 100644
--- a/gcc/testsuite/lib/target-utils.exp
+++ b/gcc/testsuite/lib/target-utils.exp
@@ -44,5 +44,13 @@ proc ${tool}_check_unsupported_p { output } {
 [string match "*exceeds local store*" $output] } {
return "memory full"
 }
+if { [string match "*error: function pointers not supported*" $output]
+ && ![check_effective_target_function_pointers] } {
+   return "function pointers not supported"
+}
+if { [string match "*error: large return values not supported*" $output]
+ && ![check_effective_target_large_return_values] } {
+   return "large return values not supported"
+}
 return ""
 }
-- 
2.11.0



[PATCH v4 09/10] testsuite: Mark that PRU uses all function pointer bits

2018-09-06 Thread Dimitar Dimitrov
gcc/testsuite/ChangeLog:

2018-08-29  Dimitar Dimitrov  

* g++.old-deja/g++.abi/ptrmem.C: Add PRU to list.

Signed-off-by: Dimitar Dimitrov 
---
 gcc/testsuite/g++.old-deja/g++.abi/ptrmem.C | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/testsuite/g++.old-deja/g++.abi/ptrmem.C 
b/gcc/testsuite/g++.old-deja/g++.abi/ptrmem.C
index 341735879c5..bda7960d8a2 100644
--- a/gcc/testsuite/g++.old-deja/g++.abi/ptrmem.C
+++ b/gcc/testsuite/g++.old-deja/g++.abi/ptrmem.C
@@ -7,7 +7,7 @@
function.  However, some platforms use all bits to encode a
function pointer.  Such platforms use the lowest bit of the delta,
that is shifted left by one bit.  */
-#if defined __MN10300__ || defined __SH5__ || defined __arm__ || defined 
__thumb__ || defined __mips__ || defined __aarch64__
+#if defined __MN10300__ || defined __SH5__ || defined __arm__ || defined 
__thumb__ || defined __mips__ || defined __aarch64__ || defined __PRU__
 #define ADJUST_PTRFN(func, virt) ((void (*)())(func))
 #define ADJUST_DELTA(delta, virt) (((delta) << 1) + !!(virt))
 #else
-- 
2.11.0



[PATCH v4 08/10] testsuite: Mark that PRU has one-cycle jumps

2018-09-06 Thread Dimitar Dimitrov
gcc/testsuite/ChangeLog:

2018-08-29  Dimitar Dimitrov  

* gcc.dg/tree-ssa/20040204-1.c: XFAIL on pru.
* gcc.dg/tree-ssa/reassoc-33.c: Ditto.
* gcc.dg/tree-ssa/reassoc-34.c: Ditto.
* gcc.dg/tree-ssa/reassoc-35.c: Ditto.
* gcc.dg/tree-ssa/reassoc-36.c: Ditto.
* gcc.dg/tree-ssa/ssa-thread-14.c: Ditto.

Signed-off-by: Dimitar Dimitrov 
---
 gcc/testsuite/gcc.dg/tree-ssa/20040204-1.c| 2 +-
 gcc/testsuite/gcc.dg/tree-ssa/reassoc-33.c| 2 +-
 gcc/testsuite/gcc.dg/tree-ssa/reassoc-34.c| 2 +-
 gcc/testsuite/gcc.dg/tree-ssa/reassoc-35.c| 2 +-
 gcc/testsuite/gcc.dg/tree-ssa/reassoc-36.c| 2 +-
 gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-14.c | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/gcc/testsuite/gcc.dg/tree-ssa/20040204-1.c 
b/gcc/testsuite/gcc.dg/tree-ssa/20040204-1.c
index a1237cf839b..06b83029fd3 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/20040204-1.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/20040204-1.c
@@ -33,4 +33,4 @@ void test55 (int x, int y)
that the && should be emitted (based on BRANCH_COST).  Fix this
by teaching dom to look through && and register all components
as true.  */
-/* { dg-final { scan-tree-dump-times "link_error" 0 "optimized" { xfail { ! 
"alpha*-*-* arm*-*-* aarch64*-*-* powerpc*-*-* cris-*-* crisv32-*-* hppa*-*-* 
i?86-*-* mmix-*-* mips*-*-* m68k*-*-* moxie-*-* nds32*-*-* s390*-*-* sh*-*-* 
sparc*-*-* spu-*-* visium-*-* x86_64-*-* riscv*-*-*" } } } } */
+/* { dg-final { scan-tree-dump-times "link_error" 0 "optimized" { xfail { ! 
"alpha*-*-* arm*-*-* aarch64*-*-* powerpc*-*-* cris-*-* crisv32-*-* hppa*-*-* 
i?86-*-* mmix-*-* mips*-*-* m68k*-*-* moxie-*-* nds32*-*-* s390*-*-* sh*-*-* 
sparc*-*-* spu-*-* visium-*-* x86_64-*-* riscv*-*-* pru*-*-*" } } } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/reassoc-33.c 
b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-33.c
index 5572df4ae24..5e1cd1a6fa7 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/reassoc-33.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-33.c
@@ -1,4 +1,4 @@
-/* { dg-do run { target { ! "m68k*-*-* mmix*-*-* bfin*-*-* v850*-*-* 
moxie*-*-* cris*-*-* m32c*-*-* fr30*-*-* mcore*-*-* powerpc*-*-* xtensa*-*-* 
hppa*-*-* nios2*-*-*"} } } */
+/* { dg-do run { target { ! "m68k*-*-* mmix*-*-* bfin*-*-* v850*-*-* 
moxie*-*-* cris*-*-* m32c*-*-* fr30*-*-* mcore*-*-* powerpc*-*-* xtensa*-*-* 
hppa*-*-* nios2*-*-* pru*-*-*"} } } */
 
 /* { dg-options "-O2 -fno-inline -fdump-tree-reassoc1-details" } */
 /* { dg-additional-options "-mbranch-cost=2" { target branch_cost } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/reassoc-34.c 
b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-34.c
index 9b45f1cd9be..a59df6a7244 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/reassoc-34.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-34.c
@@ -1,4 +1,4 @@
-/* { dg-do run { target { ! "m68k*-*-* mmix*-*-* bfin*-*-* v850*-*-* 
moxie*-*-* cris*-*-* m32c*-*-* fr30*-*-* mcore*-*-* powerpc*-*-* xtensa*-*-* 
hppa*-*-* nios2*-*-*"} } } */
+/* { dg-do run { target { ! "m68k*-*-* mmix*-*-* bfin*-*-* v850*-*-* 
moxie*-*-* cris*-*-* m32c*-*-* fr30*-*-* mcore*-*-* powerpc*-*-* xtensa*-*-* 
hppa*-*-* nios2*-*-* pru*-*-*"} } } */
 
 /* { dg-options "-O2 -fno-inline -fdump-tree-reassoc1-details" } */
 /* { dg-additional-options "-mbranch-cost=2" { target branch_cost } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/reassoc-35.c 
b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-35.c
index 9ee3abca04e..21239372709 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/reassoc-35.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-35.c
@@ -1,4 +1,4 @@
-/* { dg-do run { target { ! "m68k*-*-* mmix*-*-* bfin*-*-* v850*-*-* 
moxie*-*-* cris*-*-* m32c*-*-* fr30*-*-* mcore*-*-* powerpc*-*-* xtensa*-*-* 
hppa*-*-* nios2*-*-*"} } } */
+/* { dg-do run { target { ! "m68k*-*-* mmix*-*-* bfin*-*-* v850*-*-* 
moxie*-*-* cris*-*-* m32c*-*-* fr30*-*-* mcore*-*-* powerpc*-*-* xtensa*-*-* 
hppa*-*-* nios2*-*-* pru*-*-*"} } } */
 
 /* { dg-options "-O2 -fno-inline -fdump-tree-reassoc1-details" } */
 /* { dg-additional-options "-mbranch-cost=2" { target branch_cost } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/reassoc-36.c 
b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-36.c
index ac3a04291b7..f8eb0954ae7 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/reassoc-36.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/reassoc-36.c
@@ -1,4 +1,4 @@
-/* { dg-do run { target { ! "m68k*-*-* mmix*-*-* bfin*-*-* v850*-*-* 
moxie*-*-* cris*-*-* m32c*-*-* fr30*-*-* mcore*-*-* powerpc*-*-* xtensa*-*-* 
hppa*-*-* nios2*-*-*"} } } */
+/* { dg-do run { target { ! "m68k*-*-* mmix*-*-* bfin*-*-* v850*-*-* 
moxie*-*-* cris*-*-* m32c*-*-* fr30*-*-* mcore*-*-* powerpc*-*-* xtensa*-*-* 
hppa*-*-* nios2*-*-* pru*-*-*"} } } */
 
 /* { dg-options "-O2 -fno-inline -fdump-tree-reassoc1-details" } */
 /* { dg-additional-options "-mbranch-cost=2" { target branch_cost } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-14.c 
b/gcc/testsuite/gcc.dg/tree-ssa/ssa-thread-14.c
index f12fb07e604..71e

[PATCH v4 10/10] testsuite: Mark testsuite that PRU has different calling convention

2018-09-06 Thread Dimitar Dimitrov
For variadic functions, the last named and all anonymous arguments
are passed on stack. Regular functions pass arguments in registers.

gcc/testsuite/ChangeLog:

2018-08-29  Dimitar Dimitrov  

* gcc.dg/builtin-apply2.c: Skip for PRU.
* gcc.dg/torture/stackalign/builtin-apply-2.c: Ditto.

Signed-off-by: Dimitar Dimitrov 
---
 gcc/testsuite/gcc.dg/builtin-apply2.c | 2 +-
 gcc/testsuite/gcc.dg/torture/stackalign/builtin-apply-2.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/testsuite/gcc.dg/builtin-apply2.c 
b/gcc/testsuite/gcc.dg/builtin-apply2.c
index 3768caa5d5a..6ede0f3054b 100644
--- a/gcc/testsuite/gcc.dg/builtin-apply2.c
+++ b/gcc/testsuite/gcc.dg/builtin-apply2.c
@@ -1,7 +1,7 @@
 /* { dg-do run } */
 /* { dg-require-effective-target untyped_assembly } */
 /* { dg-skip-if "Variadic funcs have all args on stack. Normal funcs have args 
in registers." { "avr-*-* nds32*-*-*" } } */
-/* { dg-skip-if "Variadic funcs use different argument passing from normal 
funcs." { "riscv*-*-*" } } */
+/* { dg-skip-if "Variadic funcs use different argument passing from normal 
funcs." { "riscv*-*-* pru-*-*" } } */
 /* { dg-skip-if "Variadic funcs use Base AAPCS.  Normal funcs use VFP 
variant." { arm*-*-* && arm_hf_eabi } } */
 
 /* PR target/12503 */
diff --git a/gcc/testsuite/gcc.dg/torture/stackalign/builtin-apply-2.c 
b/gcc/testsuite/gcc.dg/torture/stackalign/builtin-apply-2.c
index d033010dc7c..8b6e693c0f2 100644
--- a/gcc/testsuite/gcc.dg/torture/stackalign/builtin-apply-2.c
+++ b/gcc/testsuite/gcc.dg/torture/stackalign/builtin-apply-2.c
@@ -9,7 +9,7 @@
 /* arm_hf_eabi: Variadic funcs use Base AAPCS.  Normal funcs use VFP variant.
avr: Variadic funcs don't pass arguments in registers, while normal funcs
 do.  */
-/* { dg-skip-if "Variadic funcs use different argument passing from normal 
funcs" { arm_hf_eabi || { avr-*-* riscv*-*-* } } } */
+/* { dg-skip-if "Variadic funcs use different argument passing from normal 
funcs" { arm_hf_eabi || { avr-*-* riscv*-*-* pru-*-* } } } */
 /* { dg-skip-if "Variadic funcs have all args on stack. Normal funcs have args 
in registers." { nds32*-*-* } } */
 /* { dg-require-effective-target untyped_assembly } */

-- 
2.11.0



Re: [PATCHv2] Handle overlength string literals in the fortan FE

2018-09-06 Thread Bernd Edlinger
On 09/05/18 20:16, Janne Blomqvist wrote:
> On Tue, Sep 4, 2018 at 10:05 AM Bernd Edlinger  > wrote:
> 
> On 03/09/2018, 21:25 Janne Blomqvist wrote:
>  > On Fri, Aug 24, 2018 at 11:06 PM Bernd Edlinger 
> mailto:bernd.edlin...@hotmail.de>>
>  > wrote:
>  >
>  >> Hi!
>  >>
>  >>
>  >> This is an alternative approach to handle overlength strings in the
>  >> Fortran FE.
>  >>
>  >
>  > Hi,
>  >
>  > can you explain a little more what the problem that this patch tries to
>  > solve is? What is an "overlength" string?
> 
> In the middle-end STRING_CST objects have a TYPE_DOMAIN
> which specifies how much memory the string constant uses,
> and what kind of characters the string constant consists of,
> and a TREE_STRING_LENGTH which specifies how many
> bytes the string value contains.
> 
> Everything is fine, if both sizes agree, or the memory size
> is larger than the string length, in which case the string is simply
> padded with zero bytes to the full length.
> 
> But things get unnecessarily complicated if the memory size
> is smaller than the string length.
> 
> In this situation we have two different use cases of STRING_CST
> which have contradicting rules:
> 
> For string literals and flexible arrays the memory size is ignored
> and the TREE_STRING_LENGTH is used to specify both the
> string length and the memory size.  Fortran does not use those.
> 
> For STRING_CST used in a CONSTRUCTOR of a string object
> the TREE_STRING_LENGTH is ignored, and only the part of the
> string value is used that fits into the memory size, the situation
> is similar to excess precision floating point values.
> 
> Now it happens that the middle-end sees a STRING_CST with
> overlength and wants to know if the string constant is properly
> zero-terminated, and it is impossible to tell, since any nul byte
> at the end of the string value might be part of the ignored excess
> precision, but this depends on where the string constant actually
> came from.
> 
> Therefore I started an effort to sanitize the STRING_CST via
> an assertion in the varasm.c where most of the string constants
> finally come along, and it triggered in two fortran test cases,
> and a few other languages of course.
> 
> This is what this patch tries to fix.
> 
> Bernd.
> 
> 
> I guess, I'm slightly confused why this mismatch happens in the first place 
> (does the Fortran frontend do something dumb wrt string declarations, or?), 
> but, Ok for trunk.
> 
> 

This is something that happens only on the test case that is mentioned in the 
comment.
If I remember correctly the string constant is 3 characters long, as well as the
type info on the STRING_CST itself, but the type of the object has only 2 byte
space for the string.  Therefore make the string shorter, and use the original 
type from
the declaration.

I am going to apply this together with the rest of the STRING_CST semantic 
patches,
once those are approved.


Thanks
Bernd.


[PATCH] S/390: Use proper rounding mode for DFP to BFD conversions

2018-09-06 Thread Andreas Krebbel
According to IEEE 754 2008 4.3 'Rounding-direction attributes' the
rounding mode of the target format needs to be used. By not setting
the value so far we have always used the DFP rounding mode.

gcc/ChangeLog:

2018-09-06  Andreas Krebbel  

* config/s390/s390.md (PFPO_RND_MODE_DFP, PFPO_RND_MODE_BFP): New
constants.
("trunc2")
("trunc2")
("extend2")
("extend2"): Set proper rounding mode
according to the target operand type.

gcc/testsuite/ChangeLog:

2018-09-06  Andreas Krebbel  

* gcc.target/s390/dfp_to_bfp_rounding.c: New test.
---
 gcc/config/s390/s390.md| 28 ++---
 .../gcc.target/s390/dfp_to_bfp_rounding.c  | 29 ++
 2 files changed, 53 insertions(+), 4 deletions(-)
 create mode 100644 gcc/testsuite/gcc.target/s390/dfp_to_bfp_rounding.c

diff --git a/gcc/config/s390/s390.md b/gcc/config/s390/s390.md
index ddf8608..537ed35 100644
--- a/gcc/config/s390/s390.md
+++ b/gcc/config/s390/s390.md
@@ -404,6 +404,10 @@
; Bitposition of operand types
(PFPO_OP0_TYPE_SHIFT  16)
(PFPO_OP1_TYPE_SHIFT   8)
+   ; Decide whether current DFP or BFD rounding mode should be used
+   ; for the conversion.
+   (PFPO_RND_MODE_DFP 0)
+   (PFPO_RND_MODE_BFP 1)
   ])
 
 ; Immediate operands for tbegin and tbeginc
@@ -5377,9 +5381,13 @@
 {
   HOST_WIDE_INT flags;
 
+  /* According to IEEE 754 2008 4.3 'Rounding-direction attributes' the
+ rounding mode of the target format needs to be used.  */
+
   flags = (PFPO_CONVERT |
PFPO_OP_TYPE_ << PFPO_OP0_TYPE_SHIFT |
-   PFPO_OP_TYPE_ << PFPO_OP1_TYPE_SHIFT);
+   PFPO_OP_TYPE_ << PFPO_OP1_TYPE_SHIFT |
+  PFPO_RND_MODE_DFP);
 
   operands[2] = GEN_INT (flags);
 })
@@ -5399,9 +5407,13 @@
 {
   HOST_WIDE_INT flags;
 
+  /* According to IEEE 754 2008 4.3 'Rounding-direction attributes' the
+ rounding mode of the target format needs to be used.  */
+
   flags = (PFPO_CONVERT |
PFPO_OP_TYPE_ << PFPO_OP0_TYPE_SHIFT |
-   PFPO_OP_TYPE_ << PFPO_OP1_TYPE_SHIFT);
+   PFPO_OP_TYPE_ << PFPO_OP1_TYPE_SHIFT |
+  PFPO_RND_MODE_BFP);
 
   operands[2] = GEN_INT (flags);
 })
@@ -5442,9 +5454,13 @@
 {
   HOST_WIDE_INT flags;
 
+  /* According to IEEE 754 2008 4.3 'Rounding-direction attributes' the
+ rounding mode of the target format needs to be used.  */
+
   flags = (PFPO_CONVERT |
PFPO_OP_TYPE_ << PFPO_OP0_TYPE_SHIFT |
-   PFPO_OP_TYPE_ << PFPO_OP1_TYPE_SHIFT);
+   PFPO_OP_TYPE_ << PFPO_OP1_TYPE_SHIFT |
+  PFPO_RND_MODE_DFP);
 
   operands[2] = GEN_INT (flags);
 })
@@ -5464,9 +5480,13 @@
 {
   HOST_WIDE_INT flags;
 
+  /* According to IEEE 754 2008 4.3 'Rounding-direction attributes' the
+ rounding mode of the target format needs to be used.  */
+
   flags = (PFPO_CONVERT |
PFPO_OP_TYPE_ << PFPO_OP0_TYPE_SHIFT |
-   PFPO_OP_TYPE_ << PFPO_OP1_TYPE_SHIFT);
+   PFPO_OP_TYPE_ << PFPO_OP1_TYPE_SHIFT |
+  PFPO_RND_MODE_BFP);
 
   operands[2] = GEN_INT (flags);
 })
diff --git a/gcc/testsuite/gcc.target/s390/dfp_to_bfp_rounding.c 
b/gcc/testsuite/gcc.target/s390/dfp_to_bfp_rounding.c
new file mode 100644
index 000..9a32abf
--- /dev/null
+++ b/gcc/testsuite/gcc.target/s390/dfp_to_bfp_rounding.c
@@ -0,0 +1,29 @@
+/* { dg-do run } */
+/* { dg-options "-O3 -mzarch -march=z10" } */
+
+/* According to IEEE 754 2008 4.3 Conversion operations between
+   different radixes must use the rounding mode of the target radix.
+   On S/390 this means passing the right value in GPR0 to PFPO
+   instruction.  */
+
+#include 
+
+double __attribute__((noclone,noinline))
+convert (_Decimal64 in)
+{
+  return (double)in;
+}
+
+int
+main ()
+{
+  fesetround (FE_UPWARD);
+
+  if (convert (1e-325DD) != __DBL_DENORM_MIN__)
+__builtin_abort ();
+
+  fesetround (FE_DOWNWARD);
+
+  if (convert (-1e-325DD) != -__DBL_DENORM_MIN__)
+__builtin_abort ();
+}
-- 
2.7.4



Re: [PATCH 19/25] GCN libgfortran.

2018-09-06 Thread Andrew Stubbs

On 05/09/18 19:14, Janne Blomqvist wrote:

Please send fortran patches to the fortran list as well!


Apologies, I was not aware of this.


Ok!


Thanks, I will commit when the rest of the port is approved.

Andrew


Re: [PATCH] Use complete_array_type on flexible array member initializers

2018-09-06 Thread Jeff Law
On 09/06/2018 05:05 AM, Bernd Edlinger wrote:
> On 09/04/18 16:30, Jeff Law wrote:
>> On 09/03/2018 06:35 AM, Bernd Edlinger wrote:
>> [ Big snip, dropping lots of context ]
>>
> No I don't think so, because at that time BRACE_ENCLOSED_INITIALIZER_P
> property does no longer work, as I explained in the previous mail.
>
> And cp_complete_array_type does use that property:
 [ ... ]
 Jason's the expert here.I'll defer to his expertise.  It just seemed
 a bit odd to me that we have a routine to "complete" an array that does
 any special C++ handling (cp_complete_array_type) and we're not using it.

>>> Agreed, I have posted an update which uses cp_complete_array_type, since
>>> Jason raised the same point.
>>>
>>> But since C++ does not need the recursion here, things are a lot more easy.
>>> The patch still completes the array type _after_ the FE is completely done 
>>> with the
>>> parsing, since I want to avoid to destroy the information too early, since 
>>> the FE is looking
>>> at the TYPE_DOMAIN==NULL at various places.
>> FYI, I don't see a follow-up for this patch?  Did I miss it?  Or is it
>> under a different subject line?
>>
>> jeff
>>
> Yes, thanks for reminding me.
> I had forgotten to post the updated patch.
> 
> So here is my latest version of the flexible array patch.
> 
> Bootstrapped and reg-tested on x86_64-pc-linux-gnu (together with the other 
> STRING_CST-v2 patches).
> Is it OK for trunk?
> 
> 
> Thanks
> Bernd.
> 
> 
> patch-flexarray.diff
> 
> 
> gcc:
> 2018-08-30  Bernd Edlinger  
> 
>   * varasm.c (output_constructor_regular_field): Check TYPE_SIZE_UNIT of
>   the init value.
> 
> c-family:
> 2018-08-30  Bernd Edlinger  
> 
>   * c-common.c (complete_flexible_array_elts): New helper function.
>   * c-common.h (complete_flexible_array_elts): Declare.
> 
> c:
> 2018-08-30  Bernd Edlinger  
> 
>   * c-decl.c (finish_decl): Call complete_flexible_array_elts.
> 
> cp:
> 2018-08-30  Bernd Edlinger  
> 
>   * decl.c (check_initializer): Call complete_flexible_array_elts.
Thanks.  I fixed up the ChangeLog entry for the cp/ change and installed
this patch.

As you've probably noted, I'm taking care of the installs on this stuff.
 I'm doing additional testing and as a result I've got a tree with your
proposed patch "push ready".  It'd be silly to not go ahead with the
push :-)



Jeff


Re: [wwwdocs] Document 87137 fix

2018-09-06 Thread Gerald Pfeifer
Hi Nathan,
On Wed, 5 Sep 2018, Nathan Sidwell wrote:
> this documents the fix for pr87137.  Discovered as a GCC-8 regression, 
> turned out to be an ABI bug.  Decided to fix the entire bug in one go. 
> Are these changes.html changes ok?

thanks for doing this!  I have minor suggestions if you don't mind;
the patch is fine if you consider these.

Index: gcc-8/changes.html
===
>   A C++ Microsoft ABI bitfield layout
>   bug,  href="https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87137";>PR87137
>   has been fixed.  A non-field declaration could cause the current
>   bitfield allocation unit to be completed, incorrectly placing a
>   following bitfield into a new allocation unit.  Microsoft ABI is
>   selected for:

Would "The Microsoft ABI" be more appropriate here?

> PowerPC, IA-32 or x86-64 targets
>   when -mms-bitfields option is specified

And "when the...option" (as you have it in the SuperH entry)?

>   GCC 8 introduced additional cases of this defect, but rather than
>   resolve only those regressions, it was decided to resolve all the
>   case of this defect at once.

Can we say "we decided"?  That makes it a feel more active. ;-)

And "cases" (plural)?


(I believe all of those all apply to gcc-9/changes.html .)

Thanks,
Gerald


Re: [PATCH] Maybe fix PR87134

2018-09-06 Thread Gerald Pfeifer
On Wed, 5 Sep 2018, Richard Biener wrote:
> So I'm testing the following then, leaving the placement new untouched
> (no init is fine) and then assign from vNULL.
> 
> 2018-09-05  Richard Biener  
> 
>   PR bootstrap/87134
>   * tree-ssa-sccvn.c (rpo_elim::eliminate_push_avail): Make sure
>   to zero-init the emplaced vec.

Unfortunately it does not fix the build on i586-unknown-freebsd10.4.

(Yes, I am trying various things to nail this one down and provide
more input or make it reproducible for you, alas without success so
far.)

Some things I found is that 

 - building for i686-unknown-freebsd10.4 instead of 
   i586-unknown-freebsd10.4 does not make a difference.
   (I tried, since Jeff referred to successful i686 builds).

 - not just builds with the system compiler (clang 3.4.1) fail, 
   but also those with GCC mainline from 20180827 do -- with the 
   same failure mode.

Gerald


Re: [PATCH]: Allow TARGET_SCHED_ADJUST_PRIORITY hook to reduce priority

2018-09-06 Thread Jeff Law
On 09/03/2018 08:32 AM, John David Anglin wrote:
> The documentation for TARGET_SCHED_ADJUST_PRIORITY indicates that the
> hook can
> reduce the priority of INSN to execute it later.  The hppa hook only
> reduces the priority
> and it has been this way for years.  However, the assert in
> sel_target_adjust_priority()
> prevents reduction of the priority.
> 
> The attached change revises the assert to allow the priority to be
> reduced to zero.
> 
> This fixes PR rtl-optimization/85458.
> 
> Tested on hppa-unknown-linux-gnu, hppa2.0w-hp-hpux11.11 and
> hppa64-hp-hpux11.11.
> 
> I must admit that this happens so infrequently that I have to wonder if
> the hook provides
> any benefit on hppa.  It was supposed to keep addil instructions close
> to the following instruction
> to reduce pressure on register %r1.
> 
> Okay?
> 
> Dave
> 
> -- 
> John David Anglin  dave.ang...@bell.net
> 
> 
> sel-sched.c.d
> 
> 
> 2018-09-03  John David Anglin  
> 
>   PR rtl-optimization/85458
>   * sel-sched.c (sel_target_adjust_priority): Allow backend adjust
>   priority hook to reduce the priority of EXPR.
OK.

And yes, this is to try and keep the addil and the next use of %r1 close
to each other and hopefully avoid spilling %r1.  I don't recall writing
this code, but according to git blame I did :-)


THe original is circa 1995.  Way back then folks were really concerned
about the quality of code the PA generated, particularly when accessing
objects in static storage.  We went to some great lengths to try and
optimize that code.

One of the significant issues was that in 1995, we didn't have IRA/LRA
and in fact we didn't have localized spilling.  So when we needed %r1 to
satisfy a spill, we had to spill every pseudo that had been allocated to
%r1 regardless of whether or not it conflicted with the need.   The
results looked truly horrific.


At that time we were also consolidating all static objects within a
translation unit into a structure.  That allowed unrelated objects to
share a single addil.  This required deep copying tree nodes -- back
when we still used obstacks and folks would happily stuff an integer
object into a tree field.  It was ultimately unmaintainable and scrapped.

One of the conclusions after doing all that work was that it ultimately
didn't really matter.  While the code looked a hell of a lot better and
was more compact, it didn't actually perform any better on the PA8000
generation hardware that was hitting the streets.  There's various
reasons for that, but the most important in my mind was that the addil
is just a constant.  So it's subject to LICM, CSE, PRE, etc.  THere's
just not that many from a dynamic instruction standpoint.  Combine that
with the capabilities of the PA8000 and how we scheduled PA8000 code and
the %r1 spill avoidance and addil elimination just wasn't a real factor
in code performance.

Anyway, the patch is fine.  Your call if you want to just kill the code
in the target file, it's just not terribly important anymore.

jeff



Re: [PATCH][OBVIOUS] Close file on return from verify-intermediate

2018-09-06 Thread Mike Stump
On Sep 5, 2018, at 6:29 AM, Joey Ye  wrote:
> This is a fix to an obvious issue in gcov.exp, where proc verify-intermediate 
> returns without closing the open file.
> 
> This can be a possible fix to PR85871. gcov-8.C diffs to other gcov testcases 
> that it invokes verify-intermediate. Not closing an open file may result in 
> random failure quietly.
> 
> It is only a possible fix as I failed to reproduce the PR85871 random failure 
> in my local machine despite continuous testing of multiple days. So I cannot 
> verify if this patch fixes the regression either.
> 
> To verify, https://gcc.gnu.org/ml/gcc-testresults/ need to be watched whether 
> gcov-8 regression will disappear completely one month after this patch 
> committed to trunk.
> 
> Tested with make check with no new regressions.
> 
> OK to trunk?

Ok.

I'm hoping that this doesn't fix that issue, as this change should not cause 
any change to correctly written code.  if it does fix it, there is at least one 
more unfortunate thing that should be fixed that remains unidentified.

Re: [PATCH] Use complete_array_type on flexible array member initializers

2018-09-06 Thread Bernd Edlinger
On 09/06/18 17:43, Jeff Law wrote:
> On 09/06/2018 05:05 AM, Bernd Edlinger wrote:
>> On 09/04/18 16:30, Jeff Law wrote:
>>> On 09/03/2018 06:35 AM, Bernd Edlinger wrote:
>>> [ Big snip, dropping lots of context ]
>>>
>> No I don't think so, because at that time BRACE_ENCLOSED_INITIALIZER_P
>> property does no longer work, as I explained in the previous mail.
>>
>> And cp_complete_array_type does use that property:
> [ ... ]
> Jason's the expert here.I'll defer to his expertise.  It just seemed
> a bit odd to me that we have a routine to "complete" an array that does
> any special C++ handling (cp_complete_array_type) and we're not using it.
>
 Agreed, I have posted an update which uses cp_complete_array_type, since
 Jason raised the same point.

 But since C++ does not need the recursion here, things are a lot more easy.
 The patch still completes the array type _after_ the FE is completely done 
 with the
 parsing, since I want to avoid to destroy the information too early, since 
 the FE is looking
 at the TYPE_DOMAIN==NULL at various places.
>>> FYI, I don't see a follow-up for this patch?  Did I miss it?  Or is it
>>> under a different subject line?
>>>
>>> jeff
>>>
>> Yes, thanks for reminding me.
>> I had forgotten to post the updated patch.
>>
>> So here is my latest version of the flexible array patch.
>>
>> Bootstrapped and reg-tested on x86_64-pc-linux-gnu (together with the other 
>> STRING_CST-v2 patches).
>> Is it OK for trunk?
>>
>>
>> Thanks
>> Bernd.
>>
>>
>> patch-flexarray.diff
>>
>>
>> gcc:
>> 2018-08-30  Bernd Edlinger  
>>
>>  * varasm.c (output_constructor_regular_field): Check TYPE_SIZE_UNIT of
>>  the init value.
>>
>> c-family:
>> 2018-08-30  Bernd Edlinger  
>>
>>  * c-common.c (complete_flexible_array_elts): New helper function.
>>  * c-common.h (complete_flexible_array_elts): Declare.
>>
>> c:
>> 2018-08-30  Bernd Edlinger  
>>
>>  * c-decl.c (finish_decl): Call complete_flexible_array_elts.
>>
>> cp:
>> 2018-08-30  Bernd Edlinger  
>>
>>  * decl.c (check_initializer): Call complete_flexible_array_elts.
> Thanks.  I fixed up the ChangeLog entry for the cp/ change and installed
> this patch.
> 
> As you've probably noted, I'm taking care of the installs on this stuff.
>   I'm doing additional testing and as a result I've got a tree with your
> proposed patch "push ready".  It'd be silly to not go ahead with the
> push :-)
> 

Ah, thanks a lot.

Okay, this is the status of the STRING-CST semantic-v2 patches:

[PATCH] Check the STRING_CSTs in varasm.c
https://gcc.gnu.org/ml/gcc-patches/2018-08/msg01569.html
=> Unfortunately I forgot to change the Title to [PATCHv2] or so.
Should I send a ping for this one?

[PATCHv2] Handle overlength strings in the C FE
https://gcc.gnu.org/ml/gcc-patches/2018-08/msg01566.html
=> Should I send a ping for this one?

[PATCHv2] Handle overlength strings in C++ FE
https://gcc.gnu.org/ml/gcc-patches/2018-08/msg01567.html
=> Apporoved, without the part in vtable-class-hierarchy.c (!)

[PATCHv2] Handle overlength string literals in the fortan FE
https://gcc.gnu.org/ml/gcc-patches/2018-08/msg01568.html
=> Approved.



Additional patches in the same area:

[PATCH] Fix not properly nul-terminated string constants in JIT
https://gcc.gnu.org/ml/gcc-patches/2018-08/msg00370.html

=> This triggered an assertion in the V1-patch only, but is no
pre-condition in the V2-semantic patch.  Anyway would be good
to get it in, since strings longer than 200 bytes will not be
zero-terminated.
  
I have a nice follow-up patch that allows non-zero terminated
strings (mostly found in Ada and GO) to go into the string merge
section.

I did not post it yet to avoid confusion, but if you are
interested to see it, I'll go ahead and post it.

Regarding the nonstr parameter in string_constant,
I still do have the impression that it would be more natural
for string_constant _not_ to care about zero-termination, but instead
move that check to c_strlen and c_getstr or similar high level
functions, where for instance also a location value would be
available.

I could imagine something like an optional out-parameter with
detailed error info

struct nonstr
{
   enum { no_error, char_type_mismatch, missing_zero_termination } err;
   tree str;
   location_t loc;
   nonstr(): err(no_error), str(NULL_TREE), loc(UNKNOWN_LOCATION) {}
};

This information would be available in c_strlen here:

   if (eltsize != tree_to_uhwi (TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (src)
 return NULL_TREE;

and here:

   /* Don't know what to return if there was no zero termination.
  Ideally this would turn into a gcc_checking_assert over time.  */
   if (len > maxelts - eltoff)
 return NULL_TREE;



Thanks
Bernd.


Re: [PATCH v2] combine: perform jump threading at the end

2018-09-06 Thread Jeff Law
On 09/05/2018 06:11 AM, Richard Biener wrote:
> On Wed, Sep 5, 2018 at 2:01 PM Ilya Leoshkevich  wrote:
>>
>> gcc/ChangeLog:
>>
>> 2018-09-05  Ilya Leoshkevich  
>>
>> PR target/80080
>> * combine.c (rest_of_handle_combine): Perform jump threading.
>>
>> gcc/testsuite/ChangeLog:
>>
>> 2018-09-05  Ilya Leoshkevich  
>>
>> PR target/80080
>> * gcc.target/s390/pr80080-4.c: New test.
>> ---
>>  gcc/combine.c | 10 --
>>  gcc/testsuite/gcc.target/s390/pr80080-4.c | 16 
>>  2 files changed, 24 insertions(+), 2 deletions(-)
>>  create mode 100644 gcc/testsuite/gcc.target/s390/pr80080-4.c
>>
>> diff --git a/gcc/combine.c b/gcc/combine.c
>> index a2649b6d5a1..818b4c5b77d 100644
>> --- a/gcc/combine.c
>> +++ b/gcc/combine.c
>> @@ -14960,10 +14960,16 @@ rest_of_handle_combine (void)
>> free_dominance_info (CDI_DOMINATORS);
>>timevar_push (TV_JUMP);
>>rebuild_jump_labels (get_insns ());
>> -  cleanup_cfg (0);
>> -  timevar_pop (TV_JUMP);
>>  }
>>
>> +  /* Combining insns can change basic blocks in a way that they end up
>> + containing a single jump_insn. This creates an opportunity to improve 
>> code
>> + with jump threading.  */
>> +  cleanup_cfg (CLEANUP_THREADING);
>> +
>> +  if (rebuild_jump_labels_after_combine)
>> +timevar_pop (TV_JUMP);
> 
> cleanup_cfg pushes its own timevar so it doesn't make sense to try covering it
> with TV_JUMP.  And rebuild_jump_labels immediately pushes TV_REBUILD_JUMP.
> 
> So I suggest to remove the timevar_push/pop of TV_JUMP here.
> 
> No comment in general about the change, maybe we can detect transforms that
> make jump-threading viable and conditionalize that properly?  Note the only
> setter of CLEANUP_THREADING guards it with flag_thread_jumps so maybe better
> do it above as well (avoids cost at -O0 for example).
The sad thing is I thought we'd killed the RTL jump threading code eons ago.

THe RTL jump threading code tries to prove that the target block has no
side effects and that we can statically determine the true/false
condition for the conditional branch at the end of the block.

This is (of course) much easier to do when the target block has no insns
other than the conditional branch.  So perhaps only do this when the
target block has just the conditional?

Hard to know if that'd work here since RTL wasn't posted.

Jeff


[PATCH, i386]: Rewrite fix_trunc patterns

2018-09-06 Thread Uros Bizjak
Hello!

Similar to recent float_truncate patch, IRA is able to generate output
memory location by itself, so there is no need to manually provide one
in the pattern. Attached patch rewrites fix_trunc (and similar)
patterns to output directly to memory operand.

2018-09-06  Uros Bizjak  

* config/i386/i386.md (fix_trunc_fisttp_i387_1): Remove.
Update callers to gen_fix_trunc_i387_fisttp
(fix_trunc_i387_fisttp): Change operand 0 predicate to
nonimmediate_operand.
(fix_trunc_i387_fisttp_with_temp): Remove insn pattern
and corresponding splitters.
(*fix_trunc_i387_1): Always expand with fix_trunc_i387.
(fix_truncdi_i387): Change operand 0 predicate to nonimmediate_operand.
(fix_truncdi_i387_with_temp): Remove insn pattern
and corresponding splitters.
(fix_trunc_i387): Change operand 0 predicate to
nonimmediate_operand.
(fix_trunc_i387_with_temp): Remove insn pattern
and corresponding splitters.
(*fistdi2_1): Remove.
(fistdi2): Ditto.
(fistdi2_with_temp): Remove insn pattern and corresponding splitters.
(lrintxfdi2): Remove expander.  Reimplement as define_insn.
(*fist2_1): Remove.
(fist2): Ditto.
(fist2_with_temp): Remove insn pattern and corresponding
splitters.
(lrintxf2): Remove expander.  Reimplement as define_insn.
(*fist2__1): Always expand with fist2_.
(fistdi2_): Change operand 0 predicate to
nonimmediate_operand.
(fistdi2__with_temp): Remove insn pattern
and corresponding splitters.
(fist2_): Change operand 0 predicate to
nonimmediate_operand.
(fist2__with_temp): Remove insn pattern
and corresponding splitters.

(*fixuns_truncsi2_avx512f_zext): Depend on TARGET_SSE_MATH.

Patch was bootstrapped and regression tested on x86_64-linux-gnu {,-m32}.

Committed to mainline SVN.

Uros.
Index: i386.md
===
--- i386.md (revision 264130)
+++ i386.md (working copy)
@@ -4736,7 +4736,7 @@
 {
   if (TARGET_FISTTP)
{
- emit_insn (gen_fix_truncdi_fisttp_i387_1 (operands[0], operands[1]));
+ emit_insn (gen_fix_truncdi_i387_fisttp (operands[0], operands[1]));
  DONE;
}
 })
@@ -4750,7 +4750,7 @@
   if (TARGET_FISTTP
   && !(TARGET_64BIT && SSE_FLOAT_MODE_P (mode) && TARGET_SSE_MATH))
{
- emit_insn (gen_fix_truncdi_fisttp_i387_1 (operands[0], operands[1]));
+ emit_insn (gen_fix_truncdi_i387_fisttp (operands[0], operands[1]));
  DONE;
}
   if (TARGET_64BIT && SSE_FLOAT_MODE_P (mode))
@@ -4773,7 +4773,7 @@
 {
   if (TARGET_FISTTP)
{
- emit_insn (gen_fix_truncsi_fisttp_i387_1 (operands[0], operands[1]));
+ emit_insn (gen_fix_truncsi_i387_fisttp (operands[0], operands[1]));
  DONE;
}
 })
@@ -4787,7 +4787,7 @@
   if (TARGET_FISTTP
   && !(SSE_FLOAT_MODE_P (mode) && TARGET_SSE_MATH))
{
- emit_insn (gen_fix_truncsi_fisttp_i387_1 (operands[0], operands[1]));
+ emit_insn (gen_fix_truncsi_i387_fisttp (operands[0], operands[1]));
  DONE;
}
   if (SSE_FLOAT_MODE_P (mode))
@@ -4811,7 +4811,7 @@
 {
   if (TARGET_FISTTP)
{
- emit_insn (gen_fix_trunchi_fisttp_i387_1 (operands[0], operands[1]));
+ emit_insn (gen_fix_trunchi_i387_fisttp (operands[0], operands[1]));
  DONE;
}
 })
@@ -4875,7 +4875,7 @@
(zero_extend:DI
  (unsigned_fix:SI
(match_operand:MODEF 1 "nonimmediate_operand" "vm"]
-  "TARGET_64BIT && TARGET_AVX512F"
+  "TARGET_64BIT && TARGET_AVX512F && TARGET_SSE_MATH"
   "vcvtt2usi\t{%1, %k0|%k0, %1}"
   [(set_attr "type" "sseicvt")
(set_attr "prefix" "evex")
@@ -4940,35 +4940,8 @@
   [(set (match_dup 2) (match_dup 1))
(set (match_dup 0) (fix:SWI48 (match_dup 2)))])
 
-(define_insn_and_split "fix_trunc_fisttp_i387_1"
-  [(set (match_operand:SWI248x 0 "nonimmediate_operand")
-   (fix:SWI248x (match_operand 1 "register_operand")))]
-  "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
-   && TARGET_FISTTP
-   && !((SSE_FLOAT_MODE_P (GET_MODE (operands[1]))
-&& (TARGET_64BIT || mode != DImode))
-   && TARGET_SSE_MATH)
-   && can_create_pseudo_p ()"
-  "#"
-  "&& 1"
-  [(const_int 0)]
-{
-  if (memory_operand (operands[0], VOIDmode))
-emit_insn (gen_fix_trunc_i387_fisttp (operands[0], operands[1]));
-  else
-{
-  operands[2] = assign_386_stack_local (mode, SLOT_TEMP);
-  emit_insn (gen_fix_trunc_i387_fisttp_with_temp (operands[0],
-   operands[1],
-   operands[2]));
-}
-  DONE;
-}
-  [(set_attr "type" "fisttp")
-   (set_attr "mode" "")])
-
 (define_insn "fix_trunc_i387_fisttp"
-  [(set (match_operand:SWI248x 0 "memory_operand" "=m")
+  [(set (match_operand:SWI248x 0 "nonimmediate_operand" "=m")
(fix:SWI248x (match_operand 1 "register_operand" "f")))
(clobber (match_scratch:XF 2 "=&1f"))]
   "X87_FLOAT_MODE_P (GET_MODE (operands[1]))
@@ -4980

Re: [PATCH] Maybe fix PR87134

2018-09-06 Thread Iain Sandoe


> On 6 Sep 2018, at 17:24, Gerald Pfeifer  wrote:
> 
> On Wed, 5 Sep 2018, Richard Biener wrote:
>> So I'm testing the following then, leaving the placement new untouched
>> (no init is fine) and then assign from vNULL.
>> 
>> 2018-09-05  Richard Biener  
>> 
>>  PR bootstrap/87134
>>  * tree-ssa-sccvn.c (rpo_elim::eliminate_push_avail): Make sure
>>  to zero-init the emplaced vec.
> 
> Unfortunately it does not fix the build on i586-unknown-freebsd10.4.
> 
> (Yes, I am trying various things to nail this one down and provide
> more input or make it reproducible for you, alas without success so
> far.)
> 
> Some things I found is that 
> 
> - building for i686-unknown-freebsd10.4 instead of 
>   i586-unknown-freebsd10.4 does not make a difference.
>   (I tried, since Jeff referred to successful i686 builds).
> 
> - not just builds with the system compiler (clang 3.4.1) fail, 
>   but also those with GCC mainline from 20180827 do -- with the 
>   same failure mode

I can confirm the same, repeatable, fail on i686-darwin10 (and it reproduces 
with -save-temps)
(and the vNULL change does not fix it there either) - don’t have access to the 
machine now until
later in the month tho.

I produced a back-trace here:

https://gist.github.com/iains/5ef0cd177ea17f6dc50f6c88cb5ac929

Iain



Re: Keep std::deque algos specializations in Debug mode

2018-09-06 Thread François Dumont

On 09/04/2018 02:59 PM, Jonathan Wakely wrote:




  template
    void
-    fill(const _Deque_iterator<_Tp, _Tp&, _Tp*>& __first,
- const _Deque_iterator<_Tp, _Tp&, _Tp*>& __last, const _Tp& 
__value)
+    fill(const _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>& 
__first,

+ const _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>& __last,
+ const _Tp& __value)
    {
-  typedef typename _Deque_iterator<_Tp, _Tp&, _Tp*>::_Self _Self;
-
-  for (typename _Self::_Map_pointer __node = __first._M_node + 1;
-   __node < __last._M_node; ++__node)
-    std::fill(*__node, *__node + _Self::_S_buffer_size(), __value);
+  typedef typename _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, 
_Tp*>::_Self

+    _Self;

  if (__first._M_node != __last._M_node)
{
  std::fill(__first._M_cur, __first._M_last, __value);
+
+  for (typename _Self::_Map_pointer __node = __first._M_node + 1;
+   __node != __last._M_node; ++__node)


Is there any particular reason to change this from using < to != for
the comparison?


I consider that the reason for having a < comparison was that this loop 
was done before checking __first._M_node != __last._M_node. As I moved 
it inside the block I also prefer to use a usual condition when 
iterating other iterators/pointers.


Isn't it a simpler operation ? Do you fear a compiler warning about it 
like we used to have in vector implementation before introducing the 
__builtin_unreachable calls ?




(This change is part of the reason I asked for the ChangeLog, but you
didn't mention it in the ChangeLog).

I had forgotten about it but I can add it in ChangeLog.


Moving it inside the condition makes sense (not only does it avoid a
branch in the single-page case, but means we fill the elements in
order).
Yes, it is the main reason I moved it, I should have signal it when I 
submit the patch.




+    std::fill(*__node, *__node + _Self::_S_buffer_size(), __value);
+
  std::fill(__last._M_first, __last._M_cur, __value);
}
  else


The rest of the code changes look fine, I just wondered about that
bit.

I do have some comments on the new tests though ...



+
+void test01()
+{
+  std::deque d;
+  for (char c = 0; c != std::numeric_limits::max(); ++c)
+    d.push_back(c);
+
+  std::deque dest(std::numeric_limits::max(), '\0');


These deques only have 127 or 255 elements (depending on
is_signed) which will fit on a single page of a deque (the
default is 512 bytes per page).

That means the tests don't exercise the logic for handling
non-contiguous blocks of memory.

Ideally we'd want to test multiple cases:

- a single page, with/without empty capacity at front/back
- multiple pages, with/without empty capacity at front/back

That would be 8 cases. I think we want to test at least a single
page and multiple pages.

I think I started to create the fill.cc which require usage of char to 
make sure it uses __builtin_memset and then extrapolated to other algos.


But I had already reviewed those tests for a patch I'll submit after 
this one so here is the revisited tests.


In this new proposal I also introduce a template alias to simplify the 
C++11 overloads. I define it in __gnu_debug to avoid polluting std 
namespace with a non-Standard thing.


    * include/bits/stl_deque.h
    (fill, copy, copy_backward, move, move_backward): Move overloads for
    std::deque iterators in std namespace.
    * include/bits/deque.tcc: Likewise.
    (fill): Move loop on nodes inside branch when first and last nodes are
    different. Replace for loop < condition on nodes with a !=.
    * include/debug/deque
    (__gnu_debug::_SDeque_iterator<>, __gnu_debug::_SDeque_const_iterator):
    New template aliases.
    (fill, copy, copy_backward, move, move_backward):
    New overloads for std::__debug::deque iterators. Forward to normal and
    optimized implementations after proper debug checks.
    * testsuite/23_containers/deque/copy.cc: New.
    * testsuite/23_containers/deque/copy_backward.cc: New.
    * testsuite/23_containers/deque/fill.cc: New.
    * testsuite/23_containers/deque/move.cc: New.
    * testsuite/23_containers/deque/move_backward.cc: New.

Tested under Linux x86_64.

Ok to commit ?

François
diff --git a/libstdc++-v3/include/bits/deque.tcc b/libstdc++-v3/include/bits/deque.tcc
index 125bcffb0c3..2a3f23a8588 100644
--- a/libstdc++-v3/include/bits/deque.tcc
+++ b/libstdc++-v3/include/bits/deque.tcc
@@ -980,22 +980,27 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
   this->_M_impl._M_finish._M_set_node(__new_nstart + __old_num_nodes - 1);
 }
 
+_GLIBCXX_END_NAMESPACE_CONTAINER
+
   // Overload for deque::iterators, exploiting the "segmented-iterator
   // optimization".
   template
 void
-fill(const _Deque_iterator<_Tp, _Tp&, _Tp*>& __first,
-	 const _Deque_iterator<_Tp, _Tp&, _Tp*>& __last, const _Tp& __value)
+fill(const _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&, _Tp*>& __first,
+	 const _GLIBCXX_STD_C::_Deque_iterator<_Tp, _Tp&,

Re: [PATCH] Maybe fix PR87134

2018-09-06 Thread Rainer Orth
Hi Iain,

> I can confirm the same, repeatable, fail on i686-darwin10 (and it
> reproduces with -save-temps)
> (and the vNULL change does not fix it there either) - don’t have access to
> the machine now until
> later in the month tho.

same here on i386-apple-darwin11, and I can easily fire off tests.

Rainer

-- 
-
Rainer Orth, Center for Biotechnology, Bielefeld University


[PATCH] Beautify reg_stack.c/get_true_reg a tiny bit

2018-09-06 Thread Uros Bizjak
2018-09-06  Uros Bizjak  

* reg-stack.c (get_true_reg) : Reorder
to fallthru to FLOAT case.

Bootstrapped and regression tested on x86_64-linux-gnu {,-m32}.

Committed to mainline SVN.

Uros.
diff --git a/gcc/reg-stack.c b/gcc/reg-stack.c
index 519ea6df75c..0f1b6d52f01 100644
--- a/gcc/reg-stack.c
+++ b/gcc/reg-stack.c
@@ -413,8 +413,9 @@ get_true_reg (rtx *pat)
/* Eliminate FP subregister accesses in favor of the
   actual FP register in use.  */
{
- rtx subreg;
- if (STACK_REG_P (subreg = SUBREG_REG (*pat)))
+ rtx subreg = SUBREG_REG (*pat);
+
+ if (STACK_REG_P (subreg))
{
  int regno_off = subreg_regno_offset (REGNO (subreg),
   GET_MODE (subreg),
@@ -427,6 +428,12 @@ get_true_reg (rtx *pat)
  pat = &XEXP (*pat, 0);
  break;
}
+
+  case FLOAT_TRUNCATE:
+   if (!flag_unsafe_math_optimizations)
+ return pat;
+   /* FALLTHRU */
+
   case FLOAT:
   case FIX:
   case FLOAT_EXTEND:
@@ -439,12 +446,6 @@ get_true_reg (rtx *pat)
  pat = &XVECEXP (*pat, 0, 0);
return pat;
 
-  case FLOAT_TRUNCATE:
-   if (!flag_unsafe_math_optimizations)
- return pat;
-   pat = &XEXP (*pat, 0);
-   break;
-
   default:
return pat;
   }


Re: [PATCH] Use complete_array_type on flexible array member initializers

2018-09-06 Thread Jeff Law
On 09/06/2018 11:12 AM, Bernd Edlinger wrote:

>>
> 
> Ah, thanks a lot.
> 
> Okay, this is the status of the STRING-CST semantic-v2 patches:
> 
> [PATCH] Check the STRING_CSTs in varasm.c
> https://gcc.gnu.org/ml/gcc-patches/2018-08/msg01569.html
> => Unfortunately I forgot to change the Title to [PATCHv2] or so.
> Should I send a ping for this one?
> 
> [PATCHv2] Handle overlength strings in the C FE
> https://gcc.gnu.org/ml/gcc-patches/2018-08/msg01566.html
> => Should I send a ping for this one?
No need to ping.  I've got it here.  What's odd is that it's regressing
87053 .

Jeff


Re: [PATCH] Use complete_array_type on flexible array member initializers

2018-09-06 Thread Jeff Law
On 09/06/2018 04:01 PM, Jeff Law wrote:
> On 09/06/2018 11:12 AM, Bernd Edlinger wrote:
> 
>>>
>>
>> Ah, thanks a lot.
>>
>> Okay, this is the status of the STRING-CST semantic-v2 patches:
>>
>> [PATCH] Check the STRING_CSTs in varasm.c
>> https://gcc.gnu.org/ml/gcc-patches/2018-08/msg01569.html
>> => Unfortunately I forgot to change the Title to [PATCHv2] or so.
>> Should I send a ping for this one?
>>
>> [PATCHv2] Handle overlength strings in the C FE
>> https://gcc.gnu.org/ml/gcc-patches/2018-08/msg01566.html
>> => Should I send a ping for this one?
> No need to ping.  I've got it here.  What's odd is that it's regressing
> 87053 .
Which is probably a sign that we've got an incorrect test for NUL
termination somewhere.
jeff


Re: [PATCH] Use complete_array_type on flexible array member initializers

2018-09-06 Thread Jeff Law
On 09/06/2018 04:16 PM, Jeff Law wrote:
> On 09/06/2018 04:01 PM, Jeff Law wrote:
>> On 09/06/2018 11:12 AM, Bernd Edlinger wrote:
>>

>>>
>>> Ah, thanks a lot.
>>>
>>> Okay, this is the status of the STRING-CST semantic-v2 patches:
>>>
>>> [PATCH] Check the STRING_CSTs in varasm.c
>>> https://gcc.gnu.org/ml/gcc-patches/2018-08/msg01569.html
>>> => Unfortunately I forgot to change the Title to [PATCHv2] or so.
>>> Should I send a ping for this one?
>>>
>>> [PATCHv2] Handle overlength strings in the C FE
>>> https://gcc.gnu.org/ml/gcc-patches/2018-08/msg01566.html
>>> => Should I send a ping for this one?
>> No need to ping.  I've got it here.  What's odd is that it's regressing
>> 87053 .
> Which is probably a sign that we've got an incorrect test for NUL
> termination somewhere.
I think I've found the issue.  I've got more testing to do, but looks
like a thinko on my part.

jeff


Re: [PATCH v2] combine: perform jump threading at the end

2018-09-06 Thread Segher Boessenkool
On Thu, Sep 06, 2018 at 12:11:09PM -0600, Jeff Law wrote:
> On 09/05/2018 06:11 AM, Richard Biener wrote:
> > On Wed, Sep 5, 2018 at 2:01 PM Ilya Leoshkevich  wrote:
> >> +  /* Combining insns can change basic blocks in a way that they end up
> >> + containing a single jump_insn. This creates an opportunity to 
> >> improve code
> >> + with jump threading.  */
> >> +  cleanup_cfg (CLEANUP_THREADING);

Please show an example of when this happens.  For almost all code it does
not happen, so please don't do it always.

Does it improve code at all?  There is a reason we do not run the expensive
cfg cleanups after every pass: they are expensive.  They are only done in
some strategically chosen places.


Segher


C++ PATCH for c++/87152, range-based for loops with initializer broken in templates

2018-09-06 Thread Marek Polacek
Turned out our range-based for loops with initializer are completely broken
in templates, because I neglected to add the init-statement to RANGE_FOR_STMT.
range-for18.C should verify we put it into the right scope.

tsubst_expr then needs to recurse on it to avoid the ICE.

Bootstrapped/regtested on x86_64-linux, ok for trunk?

2018-09-06  Marek Polacek  

PR c++/87152 - range-based for loops with initializer broken in 
templates.
* constexpr.c (potential_constant_expression_1) :
Recur into RANGE_FOR_INIT_STMT.
* cp-tree.def: Add RANGE_FOR_INIT_STMT to RANGE_FOR_STMT.
* cp-tree.h (RANGE_FOR_INIT_STMT): Define.
* dump.c (cp_dump_tree) : Also dump
RANGE_FOR_INIT_STMT.
* pt.c (tsubst_expr) : Recur into
RANGE_FOR_INIT_STMT.
* semantics.c (begin_range_for_stmt): Adjust call to build_stmt.
Do put the init statement in RANGE_FOR_INIT_STMT.
(finish_range_for_decl): Pop it for templates.

* g++.dg/cpp2a/range-for11.C: New test.
* g++.dg/cpp2a/range-for12.C: New test.
* g++.dg/cpp2a/range-for13.C: New test.
* g++.dg/cpp2a/range-for14.C: New test.
* g++.dg/cpp2a/range-for15.C: New test.
* g++.dg/cpp2a/range-for16.C: New test.
* g++.dg/cpp2a/range-for17.C: New test.
* g++.dg/cpp2a/range-for18.C: New test.
* g++.dg/parse/error61.C (foo): Adjust dg-error.

diff --git gcc/cp/constexpr.c gcc/cp/constexpr.c
index f646519135f..6c2689064f3 100644
--- gcc/cp/constexpr.c
+++ gcc/cp/constexpr.c
@@ -5767,6 +5767,8 @@ potential_constant_expression_1 (tree t, bool want_rval, 
bool strict, bool now,
   return true;
 
 case RANGE_FOR_STMT:
+  if (!RECUR (RANGE_FOR_INIT_STMT (t), any))
+   return false;
   if (!RECUR (RANGE_FOR_EXPR (t), any))
return false;
   if (!RECUR (RANGE_FOR_BODY (t), any))
diff --git gcc/cp/cp-tree.def gcc/cp/cp-tree.def
index 1b0326f4e81..c64225ded6f 100644
--- gcc/cp/cp-tree.def
+++ gcc/cp/cp-tree.def
@@ -301,9 +301,10 @@ DEFTREECODE (IF_STMT, "if_stmt", tcc_statement, 4)
 DEFTREECODE (FOR_STMT, "for_stmt", tcc_statement, 5)
 
 /* Used to represent a range-based `for' statement. The operands are
-   RANGE_FOR_DECL, RANGE_FOR_EXPR, RANGE_FOR_BODY, and RANGE_FOR_SCOPE,
-   RANGE_FOR_UNROLL respectively.  Only used in templates.  */
-DEFTREECODE (RANGE_FOR_STMT, "range_for_stmt", tcc_statement, 5)
+   RANGE_FOR_DECL, RANGE_FOR_EXPR, RANGE_FOR_BODY, RANGE_FOR_SCOPE,
+   RANGE_FOR_UNROLL, and RANGE_FOR_INIT_STMT, respectively.  Only used in
+   templates.  */
+DEFTREECODE (RANGE_FOR_STMT, "range_for_stmt", tcc_statement, 6)
 
 /* Used to represent a 'while' statement. The operands are WHILE_COND
and WHILE_BODY, respectively.  */
diff --git gcc/cp/cp-tree.h gcc/cp/cp-tree.h
index df441fca304..b78e9eb252b 100644
--- gcc/cp/cp-tree.h
+++ gcc/cp/cp-tree.h
@@ -4923,6 +4923,7 @@ more_aggr_init_expr_args_p (const 
aggr_init_expr_arg_iterator *iter)
 #define RANGE_FOR_BODY(NODE)   TREE_OPERAND (RANGE_FOR_STMT_CHECK (NODE), 2)
 #define RANGE_FOR_SCOPE(NODE)  TREE_OPERAND (RANGE_FOR_STMT_CHECK (NODE), 3)
 #define RANGE_FOR_UNROLL(NODE) TREE_OPERAND (RANGE_FOR_STMT_CHECK (NODE), 4)
+#define RANGE_FOR_INIT_STMT(NODE) TREE_OPERAND (RANGE_FOR_STMT_CHECK (NODE), 5)
 #define RANGE_FOR_IVDEP(NODE)  TREE_LANG_FLAG_6 (RANGE_FOR_STMT_CHECK (NODE))
 
 #define SWITCH_STMT_COND(NODE) TREE_OPERAND (SWITCH_STMT_CHECK (NODE), 0)
diff --git gcc/cp/dump.c gcc/cp/dump.c
index 9c1e5fc781a..d9b868bfaef 100644
--- gcc/cp/dump.c
+++ gcc/cp/dump.c
@@ -301,6 +301,7 @@ cp_dump_tree (void* dump_info, tree t)
 
 case RANGE_FOR_STMT:
   dump_stmt (di, t);
+  dump_child ("init", RANGE_FOR_INIT_STMT (t));
   dump_child ("decl", RANGE_FOR_DECL (t));
   dump_child ("expr", RANGE_FOR_EXPR (t));
   dump_child ("body", RANGE_FOR_BODY (t));
diff --git gcc/cp/pt.c gcc/cp/pt.c
index 0a618a5447d..892a387cbc5 100644
--- gcc/cp/pt.c
+++ gcc/cp/pt.c
@@ -16815,6 +16815,7 @@ tsubst_expr (tree t, tree args, tsubst_flags_t 
complain, tree in_decl,
 stmt = (processing_template_decl
? begin_range_for_stmt (NULL_TREE, NULL_TREE)
: begin_for_stmt (NULL_TREE, NULL_TREE));
+   RECUR (RANGE_FOR_INIT_STMT (t));
 decl = RANGE_FOR_DECL (t);
 decl = tsubst (decl, args, complain, in_decl);
 maybe_push_decl (decl);
diff --git gcc/cp/semantics.c gcc/cp/semantics.c
index 676de011868..f3e5d83b1ef 100644
--- gcc/cp/semantics.c
+++ gcc/cp/semantics.c
@@ -1101,8 +1101,8 @@ begin_range_for_stmt (tree scope, tree init)
 {
   begin_maybe_infinite_loop (boolean_false_node);
 
-  tree r = build_stmt (input_location, RANGE_FOR_STMT,
-  NULL_TREE, NULL_TREE, NULL_TREE, NULL_TREE, NULL_TREE);
+  tree r = build_stmt (input_location, RANGE_FOR_STMT, NULL_TREE, NULL_TREE,
+  NULL_TREE, NULL_TREE, NULL_TREE, NULL_TREE);
 
   if (scope == NULL_TREE)
 {
@@ -1110,22 +

C++ PATCH for c++/87150, wrong ctor with maybe-rvalue semantics

2018-09-06 Thread Marek Polacek
Another case where we weren't respecting the [class.copy.elision]/3 rule that
"if the type of the first parameter of the selected constructor is not an
rvalue reference to the object's type (possibly cv-qualified), overload
resolution is performed again, considering the object as an lvalue." In this
case the types differ because of the derived-to-base conversion.  As a result,
we chose the wrong ctor.

It seems that if we set rvaluedness_matches_p for ck_base, build_over_call
then correctly returns error_mark_node for such ctor, because if sees that
the CONVERSION_RANK is unsuitable.

Bootstrapped/regtested on x86_64-linux, ok for trunk?

2018-09-06  Marek Polacek  

PR c++/87150 - wrong ctor with maybe-rvalue semantics.
* call.c (struct conversion): Update commentary.
(standard_conversion): Set rvaluedness_matches_p if LOOKUP_PREFER_RVALUE
for ck_base.

* g++.dg/cpp0x/move-return2.C: New test.

diff --git gcc/cp/call.c gcc/cp/call.c
index 942b2c204be..03b4c5ab224 100644
--- gcc/cp/call.c
+++ gcc/cp/call.c
@@ -102,10 +102,10 @@ struct conversion {
   BOOL_BITFIELD base_p : 1;
   /* If KIND is ck_ref_bind, true when either an lvalue reference is
  being bound to an lvalue expression or an rvalue reference is
- being bound to an rvalue expression.  If KIND is ck_rvalue,
+ being bound to an rvalue expression.  If KIND is ck_rvalue or ck_base,
  true when we are treating an lvalue as an rvalue (12.8p33).  If
- KIND is ck_base, always false.  If ck_identity, we will be
- binding a reference directly or decaying to a pointer.  */
+ ck_identity, we will be binding a reference directly or decaying to
+ a pointer.  */
   BOOL_BITFIELD rvaluedness_matches_p: 1;
   BOOL_BITFIELD check_narrowing: 1;
   /* Whether check_narrowing should only check TREE_CONSTANTs; used
@@ -1425,6 +1425,9 @@ standard_conversion (tree to, tree from, tree expr, bool 
c_cast_p,
 type.  A temporary object is created to hold the result of
 the conversion unless we're binding directly to a reference.  */
   conv->need_temporary_p = !(flags & LOOKUP_NO_TEMP_BIND);
+  if (flags & LOOKUP_PREFER_RVALUE)
+   /* Tell convert_like_real to set LOOKUP_PREFER_RVALUE.  */
+   conv->rvaluedness_matches_p = true;
 }
   else
 return NULL;
diff --git gcc/testsuite/g++.dg/cpp0x/move-return2.C 
gcc/testsuite/g++.dg/cpp0x/move-return2.C
index e69de29bb2d..681e9ecaca1 100644
--- gcc/testsuite/g++.dg/cpp0x/move-return2.C
+++ gcc/testsuite/g++.dg/cpp0x/move-return2.C
@@ -0,0 +1,11 @@
+// PR c++/87150
+// { dg-do compile { target c++11 } }
+
+struct S1 { S1(S1 &&); };
+struct S2 : S1 {};
+
+S1
+f (S2 s)
+{
+  return s; // { dg-error "use of deleted function" }
+}


Re: [PATCH] Use complete_array_type on flexible array member initializers

2018-09-06 Thread Bernd Edlinger
On 09/07/18 00:26, Jeff Law wrote:
> On 09/06/2018 04:16 PM, Jeff Law wrote:
>> On 09/06/2018 04:01 PM, Jeff Law wrote:
>>> On 09/06/2018 11:12 AM, Bernd Edlinger wrote:
>>>
>

 Ah, thanks a lot.

 Okay, this is the status of the STRING-CST semantic-v2 patches:

 [PATCH] Check the STRING_CSTs in varasm.c
 https://gcc.gnu.org/ml/gcc-patches/2018-08/msg01569.html
 => Unfortunately I forgot to change the Title to [PATCHv2] or so.
 Should I send a ping for this one?

 [PATCHv2] Handle overlength strings in the C FE
 https://gcc.gnu.org/ml/gcc-patches/2018-08/msg01566.html
 => Should I send a ping for this one?
>>> No need to ping.  I've got it here.  What's odd is that it's regressing
>>> 87053 .
>> Which is probably a sign that we've got an incorrect test for NUL
>> termination somewhere.

It may be a sign that we should first fix the low level functions
before the high level stuff.

> I think I've found the issue.  I've got more testing to do, but looks
> like a thinko on my part.
> 

Ah, I forgot, the regression on pr87053 and fortran.dg/pr45636.f90
is fixed by this patch:

[PATCH] Adjust c_getstr/c_strlen to new STRING_CST semantic
https://gcc.gnu.org/ml/gcc-patches/2018-08/msg02013.html

This is a new regression since the patch was initially posted.


Bernd.