Re: [PATCH v5 1/19] modula2 front end: changes outside gcc/m2, libgm2 and gcc/testsuite. Addendum.

2022-12-11 Thread Richard Biener via Gcc-patches
On Sat, Dec 10, 2022 at 12:29 PM Gaius Mulley via Gcc-patches
 wrote:
>
>
> This patch contains a replacement doc/gm2.texi which uses American
> spelling, all references to gm2 outside the gcc tree purged and the
> News/Obtaining sections have been removed.
>
> Also included at the end is the lang.opt file for reference.

LGTM.

>
> diff -ruw /dev/null gcc-git-devel-modula2/gcc/doc/gm2.texi
> --- /dev/null   2022-08-24 16:22:16.88870 +0100
> +++ gcc-git-devel-modula2/gcc/doc/gm2.texi  2022-12-10 10:58:06.177440039 
> +
> @@ -0,0 +1,2843 @@
> +\input texinfo
> +@c -*-texinfo-*-
> +@c Copyright (C) 2001-2022 Free Software Foundation, Inc.
> +@c This is part of the GM2 manual.
> +
> +@c User level documentation for GNU Modula-2
> +@c
> +@c header
> +
> +@setfilename gm2.info
> +@settitle The GNU Modula-2 Compiler
> +
> +@set version-python  3.5
> +
> +@include gcc-common.texi
> +
> +@c Copyright years for this manual.
> +@set copyrights-gm2 1999-2022
> +
> +@copying
> +@c man begin COPYRIGHT
> +Copyright @copyright{} @value{copyrights-gm2} Free Software Foundation, Inc.
> +
> +Permission is granted to copy, distribute and/or modify this document
> +under the terms of the GNU Free Documentation License, Version 1.3 or
> +any later version published by the Free Software Foundation; with no
> +Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
> +A copy of the license is included in the
> +@c man end
> +section entitled ``GNU Free Documentation License''.
> +@ignore
> +@c man begin COPYRIGHT
> +man page gfdl(7).
> +@c man end
> +@end ignore
> +@end copying
> +
> +@ifinfo
> +@format
> +@dircategory Software development
> +@direntry
> +* gm2: (gm2).   A GCC-based compiler for the Modula-2 language
> +@end direntry
> +@end format
> +
> +@insertcopying
> +@end ifinfo
> +
> +@titlepage
> +@title The GNU Modula-2 Compiler
> +@versionsubtitle
> +@author Gaius Mulley
> +
> +@page
> +@vskip 0pt plus 1filll
> +Published by the Free Software Foundation @*
> +51 Franklin Street, Fifth Floor@*
> +Boston, MA 02110-1301, USA@*
> +@sp 1
> +@insertcopying
> +@end titlepage
> +@contents
> +@page
> +
> +@c `Top' Node and Master Menu
> +
> +@node Top, Overview, (dir), (dir)
> +@top Introduction
> +
> +@menu
> +* Overview:: What is GNU Modula-2.
> +* Using::Using GNU Modula-2.
> +* Licence::  Licence of GNU Modula-2
> +* Copying::  GNU Public Licence V3.
> +* Contributing:: Contributing to GNU Modula-2
> +* Internals::GNU Modula-2 internals.
> +* EBNF:: EBNF of GNU Modula-2
> +* Libraries::PIM and ISO library definitions.
> +* Indices::  Document and function indices.
> +@end menu
> +
> +@node Overview, Using, Top, Top
> +@chapter Overview of GNU Modula-2
> +
> +@menu
> +* What is GNU Modula-2::  Brief description of GNU Modula-2.
> +* Why use GNU Modula-2::  Advantages of GNU Modula-2.
> +* Development::   How to get source code using git.
> +* Features::  GNU Modula-2 Features
> +@end menu
> +
> +@node What is GNU Modula-2, Why use GNU Modula-2, , Using
> +@section What is GNU Modula-2
> +
> +GNU Modula-2 is a @uref{http://gcc.gnu.org/frontends.html, front end}
> +for the GNU Compiler Collection (@uref{http://gcc.gnu.org/, GCC}).
> +The GNU Modula-2 compiler is compliant with the PIM2, PIM3, PIM4 and
> +ISO dialects.  Also implemented are a complete set of free ISO
> +libraries and PIM libraries.
> +
> +@footnote{The four Modula-2 dialects supported are defined in the following
> +references:
> +
> +PIM2: 'Programming in Modula-2', 2nd Edition, Springer Verlag, 1982,
> +1983 by Niklaus Wirth (PIM2).
> +
> +PIM3: 'Programming in Modula-2', 3rd Corrected Edition, Springer Verlag,
> +1985 (PIM3).
> +
> +PIM4: 'Programming in Modula-2', 4th Edition, Springer Verlag, 1988
> +(@uref{http://freepages.modula2.org/report4/modula-2.html, PIM4}).
> +
> +ISO: the ISO Modula-2 language as defined in 'ISO/IEC Information
> +technology - programming languages - part 1: Modula-2 Language,
> +ISO/IEC 10514-1 (1996)'
> +}
> +
> +@node Why use GNU Modula-2, Release map, What is GNU Modula-2, Using
> +@section Why use GNU Modula-2
> +
> +There are a number of advantages of using GNU Modula-2 rather than
> +translate an existing project into another language.
> +
> +The first advantage is of maintainability of the original sources
> +and the ability to debug the original project source code using a
> +combination of gm2 and gdb.
> +
> +The second advantage is that gcc runs on many processors and
> +platforms.  gm2 builds and runs on powerpc64le, amd64, i386, aarch64
> +to name but a few processors.
> +
> +gm2 can produce swig interface headers to allow access from Python and
> +other scripting languages.  It can also be used with C/C++ and
> +generate shared libraries.
> +
> +The compiler provides semantic analysis and runtime checking (full ISO
> +Modula-2 checking is implemented) and there is a plugin which can,
> +

Re: [PATCH v5 1/19] modula2 front end: changes outside gcc/m2, libgm2 and gcc/testsuite. Addendum.

2022-12-11 Thread Gaius Mulley via Gcc-patches
Richard Biener  writes:

> On Sat, Dec 10, 2022 at 12:29 PM Gaius Mulley via Gcc-patches
>  wrote:
>>
>>
>> This patch contains a replacement doc/gm2.texi which uses American
>> spelling, all references to gm2 outside the gcc tree purged and the
>> News/Obtaining sections have been removed.
>>
>> Also included at the end is the lang.opt file for reference.
>
> LGTM.

thanks!


Re: [PATCH v4 1/19] modula2 front end: changes outside gcc/m2, libgm2 and gcc/testsuite.

2022-12-11 Thread Richard Biener via Gcc-patches
On Sat, Dec 10, 2022 at 1:49 AM Gaius Mulley via Gcc-patches
 wrote:
>
>
> While writing the ChangeLog entries git gcc-verify spotted an oversight
> with v3 of this patch set.  I had forgotten to post gm2.texi and also a
> tiny patchlet in gcc/configure.ac (to detect Python).  HAVE_PYTHON is
> used within gcc/m2/Make-lang.in to avoid generating the library section
> included by gm2.texi should Python not be available.

The configure check doesn't verify the python version.  Does
--enable-generated-files-in-srcdir (used when building release
tarballs) generate the required section so it's packed up in the
release tarball and avoid requiring python3 when building from the
release tarball?

Note these kind of dependences should be mentioned in
install.texi - for python also listing required modules would be nice.

Thanks,
Richard.

> ok to commit?  I've included gm2-lang.cc and lang.opt for reference.

The python script would have been more informative, the generated
.texi fragment and the Make-lang.in part as well

> regards,
> Gaius
>
>
>
>
> diff -ruw gcc-git-master/gcc/configure.ac 
> gcc-git-devel-modula2/gcc/configure.ac
> --- gcc-git-master/gcc/configure.ac 2022-12-07 20:16:24.571677189 +
> +++ gcc-git-devel-modula2/gcc/configure.ac  2022-12-07 19:46:20.036302786 
> +
> @@ -1263,6 +1263,10 @@
>  # Bison?
>  AC_CHECK_PROGS([BISON], bison, [$MISSING bison])
>
> +# Python3?
> +AM_PATH_PYTHON(,, [:])
> +AM_CONDITIONAL([HAVE_PYTHON], [test "$PYTHON" != :])
> +
>  # Binutils are not build modules, unlike bison/flex/makeinfo.  So we
>  # check for build == host before using them.
>
> @@ -7651,4 +7655,3 @@
>  ],
>  [subdirs='$subdirs'])
>  AC_OUTPUT
> -
> diff -ruw /dev/null gcc-git-devel-modula2/gcc/doc/gm2.texi
> --- /dev/null   2022-08-24 16:22:16.88870 +0100
> +++ gcc-git-devel-modula2/gcc/doc/gm2.texi  2022-12-10 00:04:30.263603238 
> +
> @@ -0,0 +1,2944 @@
> +\input texinfo
> +@c -*-texinfo-*-
> +@c Copyright (C) 2001-2022 Free Software Foundation, Inc.
> +@c This is part of the GM2 manual.
> +
> +@c User level documentation for GNU Modula-2
> +@c
> +@c header
> +
> +@setfilename gm2.info
> +@settitle The GNU Modula-2 Compiler
> +
> +@set version-python  3.5
> +
> +@include gcc-common.texi
> +
> +@c Copyright years for this manual.
> +@set copyrights-gm2 1999-2022
> +
> +@copying
> +@c man begin COPYRIGHT
> +Copyright @copyright{} @value{copyrights-gm2} Free Software Foundation, Inc.
> +
> +Permission is granted to copy, distribute and/or modify this document
> +under the terms of the GNU Free Documentation License, Version 1.3 or
> +any later version published by the Free Software Foundation; with no
> +Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
> +A copy of the license is included in the
> +@c man end
> +section entitled ``GNU Free Documentation License''.
> +@ignore
> +@c man begin COPYRIGHT
> +man page gfdl(7).
> +@c man end
> +@end ignore
> +@end copying
> +
> +@ifinfo
> +@format
> +@dircategory Software development
> +@direntry
> +* gm2: (gm2).   A GCC-based compiler for the Modula-2 language
> +@end direntry
> +@end format
> +
> +@insertcopying
> +@end ifinfo
> +
> +@titlepage
> +@title The GNU Modula-2 Compiler
> +@versionsubtitle
> +@author Gaius Mulley
> +
> +@page
> +@vskip 0pt plus 1filll
> +Published by the Free Software Foundation @*
> +51 Franklin Street, Fifth Floor@*
> +Boston, MA 02110-1301, USA@*
> +@sp 1
> +@insertcopying
> +@end titlepage
> +@contents
> +@page
> +
> +@c `Top' Node and Master Menu
> +
> +@node Top, Overview, (dir), (dir)
> +@top Introduction
> +
> +@menu
> +* Overview:: What is GNU Modula-2.
> +* Using::Using GNU Modula-2.
> +* Licence::  Licence of GNU Modula-2
> +* Copying::  GNU Public Licence V3.
> +* Contributing:: Contributing to GNU Modula-2
> +* Internals::GNU Modula-2 internals.
> +* EBNF:: EBNF of GNU Modula-2
> +* Libraries::PIM and ISO library definitions.
> +* Indices::  Document and function indices.
> +@end menu
> +
> +@node Overview, Using, Top, Top
> +@chapter Overview of GNU Modula-2
> +
> +@menu
> +* What is GNU Modula-2::  Brief description of GNU Modula-2.
> +* Why use GNU Modula-2::  Advantages of GNU Modula-2.
> +* News::  Latest news about GNU Modula-2.
> +* Development::   How to get source code using git.
> +* Obtaining:: Where to get the source code using git.
> +* Features::  GNU Modula-2 Features
> +@end menu
> +
> +@node What is GNU Modula-2, Why use GNU Modula-2, , Using
> +@section What is GNU Modula-2
> +
> +GNU Modula-2 is a @uref{http://gcc.gnu.org/frontends.html, front end}
> +for the GNU Compiler Collection (@uref{http://gcc.gnu.org/, GCC}).
> +The GNU Modula-2 compiler is compliant with the PIM2, PIM3, PIM4 and
> +ISO dialects.  Also implemented are a complete set of free ISO
> +libraries and PIM libraries.
> +
> +@footnote{The four Modula-2 dial

Re: [PATCH] Backport gcc-12: jobserver FIFO support

2022-12-11 Thread Richard Biener via Gcc-patches
On Fri, Dec 9, 2022 at 11:07 AM Martin Liška  wrote:
>
> Hi.
>
> As make 4.4 has been release, it switches to FIFO by default. That makes
> troubles to the latest GCC release, version 12.

Can you elaborate on "troubles" here?  I'm fine with backporting the whole
series to GCC 12 but I wonder if earlier still maintained versions are also
affected (noting that the series also addresses WPA streaming which is
not part of the "troubles" here).

Thanks,
Richard.

> Right now, we've been using
> the following 4 patches in openSUSE gcc12 package:
>
> 1270ccda70ca09f7d4fe76b5156dca8992bd77a6
> 53e3b2bf16a486c15c20991c6095f7be09012b55
> fed766af32ed6cd371016cc24e931131e19b4eb1
> 3f1c2f89f6b8b8d23a9072f8549b0a2c1de06b03
>
> Would it be fine to backport it to gcc-12 branch? Arsen asked me the today
> as Gentoo people want it as well.
>
> Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
>
> Ready to be installed?
> Thanks,
> Martin


[committed] fortran/openmp.cc: Remove 's' that slipped in during %<..%> replacement (was: [Patch] Fortran: Replace simple '.' quotes by %<.%>)

2022-12-11 Thread Tobias Burnus

On 09.12.22 22:12, Tobias Burnus wrote:

Found when working on the just submitted/committed patch.


Committed as r13-4590 –  but it required a follow-up that I somehow
missed :-/ but that is now committed as well (as r13-4597).

Tobias
-
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 
München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas 
Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht 
München, HRB 106955
commit 045592f665bcb67b75dc6b86badbe2fd44aed3e6
Author: Tobias Burnus 
Date:   Sun Dec 11 11:47:55 2022 +0100

fortran/openmp.cc: Remove 's' that slipped in during %<..%> replacement

Seemingly, 's' (in VI that's the 's'ubstitute command) appeared verbatim in
a gfc_error message when to doing the '...' to %<...%> replacements in commit
r13-4590-g84f6f8a2a97f88be01e223c9c9dbab801a4f501f

gcc/fortran/
* openmp.cc (gfc_match_omp_context_selector_specification):
Remove spurious 's' in an error message.
---
 gcc/fortran/openmp.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/fortran/openmp.cc b/gcc/fortran/openmp.cc
index 7edc78ad0cb..686f924b47a 100644
--- a/gcc/fortran/openmp.cc
+++ b/gcc/fortran/openmp.cc
@@ -5568,7 +5568,7 @@ gfc_match_omp_context_selector_specification (gfc_omp_declare_variant *odv)
 
   if (m != MATCH_YES || i == selector_set_count)
 	{
-	  gfc_error ("expected %, %, % "
+	  gfc_error ("expected %, %, % "
 		 "or % at %C");
 	  return MATCH_ERROR;
 	}


[PATCH 1/2] Treat ADDR_EXPR and CONSTRUCTOR as GIMPLE/GENERIC magically

2022-12-11 Thread Richard Biener via Gcc-patches
The following allows to match ADDR_EXPR for both the invariant
&a.b case as well as the &p->d case in a separate definition
transparently.  This also allows to remove the hack we employ
for CONSTRUCTOR which we handle for example with

 (match vec_same_elem_p
  CONSTRUCTOR@0
  (if (TREE_CODE (@0) == SSA_NAME
   && uniform_vector_p (gimple_assign_rhs1 (SSA_NAME_DEF_STMT (@0))

Note CONSTUCTORs always appear as separate definition in GIMPLE,
but I continue to play safe and ADDR_EXPRs are now matched in
both places where previously ADDR_EXPR@0 would have missed
the &p->x case.

This is a prerequesite for the PR89317 fix.

Bootstrapped and tested on x86_64-unknown-linux-gnu, will push
after testing of the 2nd patch succeeded.

* genmatch.cc (dt_node::gen_kids): Handle ADDR_EXPR in both
the GENERIC and GIMPLE op position.
(dt_simplify::gen): Capture both GENERIC and GIMPLE op
position for ADDR_EXPR and CONSTRUCTOR.
* match.pd: Simplify CONSTRUCTOR leaf handling.

* gcc.dg/tree-ssa/forwprop-3.c: Adjust.
* g++.dg/tree-ssa/pr31146-2.C: Likewise.
---
 gcc/genmatch.cc| 30 ++
 gcc/match.pd   | 12 +++--
 gcc/testsuite/g++.dg/tree-ssa/pr31146-2.C  |  2 +-
 gcc/testsuite/gcc.dg/tree-ssa/forwprop-3.c |  2 +-
 4 files changed, 31 insertions(+), 15 deletions(-)

diff --git a/gcc/genmatch.cc b/gcc/genmatch.cc
index 4a8802469cd..f53e61a4a8d 100644
--- a/gcc/genmatch.cc
+++ b/gcc/genmatch.cc
@@ -2927,8 +2927,16 @@ dt_node::gen_kids (FILE *f, int indent, bool gimple, int 
depth)
  if (expr *e = dyn_cast  (op->op))
{
  if (e->ops.length () == 0
+ /* In GIMPLE a CONSTRUCTOR always appears in a
+separate definition.  */
  && (!gimple || !(*e->operation == CONSTRUCTOR)))
-   generic_exprs.safe_push (op);
+   {
+ generic_exprs.safe_push (op);
+ /* But ADDR_EXPRs can appear directly when invariant
+and in a separate definition when not.  */
+ if (gimple && *e->operation == ADDR_EXPR)
+   gimple_exprs.safe_push (op);
+   }
  else if (e->operation->kind == id_base::FN)
{
  if (gimple)
@@ -3599,14 +3607,26 @@ dt_simplify::gen (FILE *f, int indent, bool gimple, int 
depth ATTRIBUTE_UNUSED)
   if (s->capture_max >= 0)
 {
   char opname[20];
-  fprintf_indent (f, indent, "tree captures[%u] ATTRIBUTE_UNUSED = { %s",
- s->capture_max + 1, indexes[0]->get_name (opname));
+  fprintf_indent (f, indent, "tree captures[%u] ATTRIBUTE_UNUSED = {",
+ s->capture_max + 1);
 
-  for (int i = 1; i <= s->capture_max; ++i)
+  for (int i = 0; i <= s->capture_max; ++i)
{
  if (!indexes[i])
break;
- fprintf (f, ", %s", indexes[i]->get_name (opname));
+ const char *opstr = indexes[i]->get_name (opname);
+ expr *e = dyn_cast  (indexes[i]->op);
+ fputs (i == 0 ? " " : ", ", f);
+ if (e && gimple
+ /* Transparently handle picking up CONSTRUCTOR and ADDR_EXPR
+leafs if they appear in a separate definition.  */
+ && (*e->operation == CONSTRUCTOR
+ || *e->operation == ADDR_EXPR))
+   fprintf (f, "(TREE_CODE (%s) == SSA_NAME "
+"? gimple_assign_rhs1 (SSA_NAME_DEF_STMT (%s)) : %s)",
+opstr, opstr, opstr);
+ else
+   fprintf (f, "%s", opstr);
}
   fprintf (f, " };\n");
 }
diff --git a/gcc/match.pd b/gcc/match.pd
index 127cef9a610..046ea2cdef4 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -3925,8 +3925,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
 (simplify
   (view_convert CONSTRUCTOR@0)
   (with
-   { tree ctor = (TREE_CODE (@0) == SSA_NAME
- ? gimple_assign_rhs1 (SSA_NAME_DEF_STMT (@0)) : @0); }
+   { tree ctor = @0; }
(switch
 (if (CONSTRUCTOR_NELTS (ctor) == 0)
  { build_zero_cst (type); })
@@ -7292,8 +7291,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
  == tree_to_uhwi (TYPE_SIZE (TREE_TYPE (TREE_TYPE (@0
   (with
{
- tree ctor = (TREE_CODE (@0) == SSA_NAME
- ? gimple_assign_rhs1 (SSA_NAME_DEF_STMT (@0)) : @0);
+ tree ctor = @0;
  tree eltype = TREE_TYPE (TREE_TYPE (ctor));
  unsigned HOST_WIDE_INT width = tree_to_uhwi (TYPE_SIZE (eltype));
  unsigned HOST_WIDE_INT n = tree_to_uhwi (@1);
@@ -7941,8 +7939,7 @@ and,
 /* Fold reduction of a single nonzero element constructor.  */
 (for reduc (IFN_REDUC_PLUS IFN_REDUC_IOR IFN_REDUC_XOR)
   (simplify (reduc (CONSTRUCTOR@0))
-(with { tree ctor = (TREE_CODE (@0) == SSA_NAME
-? gimple_assign_rhs1 (SSA_NAME_DEF_STMT (@0)) : @0);
+(with { tree ctor = @0;
   

gcc-patches@gcc.gnu.org

2022-12-11 Thread Richard Biener via Gcc-patches
The PR notices we fail to simplify

  a_4 = &x_3(D)->data;
  b_5 = x_3(D) + 16;
  _1 = b_5 - a_4;

together with the enabler handling ADDR_EXPR leafs in separate
stmts in match.pd the suggested patterns work.

Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.

PR tree-optimization/89317
* match.pd ((p + b) - &p->c -> b - offsetof(c)): New patterns.

* gcc.dg/tree-ssa/pr89317.c: New testcase.
---
 gcc/match.pd| 11 +++
 gcc/testsuite/gcc.dg/tree-ssa/pr89317.c | 13 +
 2 files changed, 24 insertions(+)
 create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/pr89317.c

diff --git a/gcc/match.pd b/gcc/match.pd
index 046ea2cdef4..ba83c69734f 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -2451,6 +2451,17 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
  (with { poly_int64 diff; }
(if (ptr_difference_const (@0, @2, &diff))
 (plus { build_int_cst_type (type, diff); } (convert (minus @1 @3))
+/* (p + b) - &p->d -> offsetof (*p, d) + b */
+(simplify
+ (pointer_diff (pointer_plus @0 @1) ADDR_EXPR@2)
+ (with { poly_int64 diff; }
+   (if (ptr_difference_const (@0, @2, &diff))
+(plus { build_int_cst_type (type, diff); } (convert @1)
+(simplify
+ (pointer_diff ADDR_EXPR@0 (pointer_plus @1 @2))
+ (with { poly_int64 diff; }
+   (if (ptr_difference_const (@0, @1, &diff))
+(minus { build_int_cst_type (type, diff); } (convert @2)
 
 /* Canonicalize (T *)(ptr - ptr-cst) to &MEM[ptr + -ptr-cst].  */
 (simplify
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr89317.c 
b/gcc/testsuite/gcc.dg/tree-ssa/pr89317.c
new file mode 100644
index 000..0d0a049454f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr89317.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fdump-tree-ccp1" } */
+
+struct b { int data[16]; };
+
+int foo (struct b *x)
+{
+  int *a = x->data;
+  int *b = ((int*)x) + 4;
+  return b - a;
+}
+
+/* { dg-final { scan-tree-dump "return 4;" "ccp1" } } */
-- 
2.35.3


Re: [PATCH] tree-optimization/106904 - bogus -Wstringopt-overflow with vectors

2022-12-11 Thread Richard Biener via Gcc-patches
On Wed, 7 Dec 2022, Richard Biener wrote:

> The following avoids CSE of &ps->wp to &ps->wp.hwnd confusing
> -Wstringopt-overflow by making sure to produce addresses to the
> biggest container from vectorization.  For this I introduce
> strip_zero_offset_components which turns &ps->wp.hwnd into
> &(*ps) and use that to base the vector data references on.
> That will also work for addresses with variable components,
> alternatively emitting pointer arithmetic via calling
> get_inner_reference and gimplifying that would be possible
> but likely more intrusive.
> 
> This is by no means a complete fix for all of those issues
> (avoiding ADDR_EXPRs in favor of pointer arithmetic might be).
> Other passes will have similar issues.
> 
> In theory that might now cause false negatives.
> 
> Bootstrap and regtest running on x86_64-unknown-linux-gnu.
> 
> Any opinion?

I have now pushed this.

Richard.

> Thanks,
> Richard.
> 
>   PR tree-optimization/106904
>   * tree.h (strip_zero_offset_components): Declare.
>   * tree.cc (strip_zero_offset_components): Define.
>   * tree-vect-data-refs.cc (vect_create_addr_base_for_vector_ref):
>   Strip zero offset components before building the address.
> 
>   * gcc.dg/Wstringop-overflow-pr106904.c: New testcase.
> ---
>  .../gcc.dg/Wstringop-overflow-pr106904.c  | 30 +++
>  gcc/tree-vect-data-refs.cc| 12 
>  gcc/tree.cc   | 12 
>  gcc/tree.h|  1 +
>  4 files changed, 50 insertions(+), 5 deletions(-)
>  create mode 100644 gcc/testsuite/gcc.dg/Wstringop-overflow-pr106904.c
> 
> diff --git a/gcc/testsuite/gcc.dg/Wstringop-overflow-pr106904.c 
> b/gcc/testsuite/gcc.dg/Wstringop-overflow-pr106904.c
> new file mode 100644
> index 000..15e67c28c15
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/Wstringop-overflow-pr106904.c
> @@ -0,0 +1,30 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O2 -Wstringop-overflow -fno-vect-cost-model" } */
> +
> +struct windowpos
> +{
> +  int hwnd;
> +  int hwnd2;
> +};
> +
> +struct packed_windowpos
> +{
> +  int hwnd;
> +  int pad1;
> +  int hwnd2;
> +  int pad2;
> +};
> +
> +struct packed_structs
> +{
> +  struct packed_windowpos wp;
> +};
> +
> +void func(struct packed_structs *ps)
> +{
> +  struct windowpos wp;
> +
> +  wp.hwnd = ps->wp.hwnd;
> +  wp.hwnd2 = ps->wp.hwnd2;
> +  __builtin_memcpy(&ps->wp, &wp, sizeof(wp)); /* { dg-bogus "into a region" 
> } */
> +}
> diff --git a/gcc/tree-vect-data-refs.cc b/gcc/tree-vect-data-refs.cc
> index 6c892791bd4..18b0f962670 100644
> --- a/gcc/tree-vect-data-refs.cc
> +++ b/gcc/tree-vect-data-refs.cc
> @@ -4845,11 +4845,13 @@ vect_create_addr_base_for_vector_ref (vec_info 
> *vinfo, stmt_vec_info stmt_info,
>if (loop_vinfo)
>  addr_base = fold_build_pointer_plus (data_ref_base, base_offset);
>else
> -{
> -  addr_base = build1 (ADDR_EXPR,
> -   build_pointer_type (TREE_TYPE (DR_REF (dr))),
> -   unshare_expr (DR_REF (dr)));
> -}
> +addr_base = build1 (ADDR_EXPR,
> + build_pointer_type (TREE_TYPE (DR_REF (dr))),
> + /* Strip zero offset components since we don't need
> +them and they can confuse late diagnostics if
> +we CSE them wrongly.  See PR106904 for example.  */
> + unshare_expr (strip_zero_offset_components
> + (DR_REF (dr;
>  
>vect_ptr_type = build_pointer_type (TREE_TYPE (DR_REF (dr)));
>dest = vect_get_new_vect_var (vect_ptr_type, vect_pointer_var, base_name);
> diff --git a/gcc/tree.cc b/gcc/tree.cc
> index b40c95ae8c4..0a51f9ddb4d 100644
> --- a/gcc/tree.cc
> +++ b/gcc/tree.cc
> @@ -12014,6 +12014,18 @@ strip_invariant_refs (const_tree op)
>return op;
>  }
>  
> +/* Strip handled components with zero offset from OP.  */
> +
> +tree
> +strip_zero_offset_components (tree op)
> +{
> +  while (TREE_CODE (op) == COMPONENT_REF
> +  && integer_zerop (DECL_FIELD_OFFSET (TREE_OPERAND (op, 1)))
> +  && integer_zerop (DECL_FIELD_BIT_OFFSET (TREE_OPERAND (op, 1
> +op = TREE_OPERAND (op, 0);
> +  return op;
> +}
> +
>  static GTY(()) tree gcc_eh_personality_decl;
>  
>  /* Return the GCC personality function decl.  */
> diff --git a/gcc/tree.h b/gcc/tree.h
> index 1c810c0b21b..065ad527c3f 100644
> --- a/gcc/tree.h
> +++ b/gcc/tree.h
> @@ -5373,6 +5373,7 @@ extern bool tree_nop_conversion_p (const_tree, 
> const_tree);
>  extern tree tree_strip_nop_conversions (tree);
>  extern tree tree_strip_sign_nop_conversions (tree);
>  extern const_tree strip_invariant_refs (const_tree);
> +extern tree strip_zero_offset_components (tree);
>  extern tree lhd_gcc_personality (void);
>  extern void assign_assembler_name_if_needed (tree);
>  extern bool warn_deprecated_use (tree, tree);
> 

-- 
Richard Biener 

[committed] d: Expand bsr intrinsic as `clz(arg) ^ (argsize - 1)'

2022-12-11 Thread Iain Buclaw via Gcc-patches
Hi,

This patch tweaks the code expansion of the D intrinsic bsr() function.

As well as removing unnecessary casts, this results in less temporaries
being generated during the initial gimple lowering pass.  Otherwise the
code generated is identical to the former intrinsic expansion.

Bootstrapped and regression tested on x86_64-linux-gnu/-m32.

Committed to mainline.

Regards,
Iain.

---
gcc/d/ChangeLog:

* intrinsics.cc (expand_intrinsic_bsf): Fix comment.
(expand_intrinsic_bsr): Use BIT_XOR_EXPR instead of MINUS_EXPR.
---
 gcc/d/intrinsics.cc | 17 ++---
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/gcc/d/intrinsics.cc b/gcc/d/intrinsics.cc
index 6d9f74a6d7a..46380e512c4 100644
--- a/gcc/d/intrinsics.cc
+++ b/gcc/d/intrinsics.cc
@@ -525,7 +525,7 @@ call_builtin_fn (tree callexp, built_in_function code, int 
n, ...)
 static tree
 expand_intrinsic_bsf (tree callexp)
 {
-  /* The bsr() intrinsic gets turned into __builtin_ctz(arg).
+  /* The bsf() intrinsic gets turned into __builtin_ctz(arg).
  The return value is supposed to be undefined if arg is zero.  */
   tree arg = CALL_EXPR_ARG (callexp, 0);
   int argsize = TYPE_PRECISION (TREE_TYPE (arg));
@@ -554,11 +554,11 @@ expand_intrinsic_bsf (tree callexp)
 static tree
 expand_intrinsic_bsr (tree callexp)
 {
-  /* The bsr() intrinsic gets turned into (size - 1) - __builtin_clz(arg).
+  /* The bsr() intrinsic gets turned into __builtin_clz(arg) ^ (size - 1).
  The return value is supposed to be undefined if arg is zero.  */
   tree arg = CALL_EXPR_ARG (callexp, 0);
-  tree type = TREE_TYPE (arg);
-  int argsize = TYPE_PRECISION (type);
+  tree type = TREE_TYPE (callexp);
+  int argsize = TYPE_PRECISION (TREE_TYPE (arg));
 
   /* Which variant of __builtin_clz* should we call?  */
   built_in_function code = (argsize <= INT_TYPE_SIZE) ? BUILT_IN_CLZ
@@ -570,13 +570,8 @@ expand_intrinsic_bsr (tree callexp)
 
   tree result = call_builtin_fn (callexp, code, 1, arg);
 
-  /* Handle int -> long conversions.  */
-  if (TREE_TYPE (result) != type)
-result = fold_convert (type, result);
-
-  result = fold_build2 (MINUS_EXPR, type,
-   build_integer_cst (argsize - 1, type), result);
-  return fold_convert (TREE_TYPE (callexp), result);
+  return fold_build2 (BIT_XOR_EXPR, type, result,
+ build_integer_cst (argsize - 1, type));
 }
 
 /* Expand a front-end intrinsic call to INTRINSIC, which is either a call to
-- 
2.37.2



Re: [PATCH] contracts: Stop relying on mangling for naming .pre/.post clones

2022-12-11 Thread Arsen Arsenović via Gcc-patches
Hi Bernhard,

Bernhard Reutner-Fischer  writes:

> From a very distant POV this auto sounds really like an ugly bandaid and I,
> personally would have used a conditional in place argument. auto is really 
> like
> c++ didn't have the guts to go straight to implicit typed LHS like python et 
> al
> nor to learn from Fortran's IMPLICIT defaults from some 60 years ago by now
> (which might have made sense on punchcards, but IMHO not so much nowadays, at
> least in the light of multi lingual people).
>
> The real change does sound plausible, but I didn't really look closely. All 
> in all, not even a comment ;-)

This actually preceded significantly more complex code in my original
revision, which got simplified by a good bit by the time I sent it out.
I didn't really feel the need to make the parameter inline since it
would only prolong the line here, I think.  I'm fine with doing that
too, though.

I don't think there's any ban on auto across the codebase either, which
is why I initially used it.

I think C++ is significantly helped by auto, since there's no need to be
specific with types in most places, as long as they can still be deduced
from context, and I think that property holds here.  An alternative
universe with fancier implicit typing does sound nice, though :D

As for the change, AFAICT, the code before and after the change still
produces the same symbols, so I think it should be generally fine across
the board, just that this time around we don't need the mangler when it
isn't used.

Thanks for the review, and have a wonderful day.
-- 
Arsen Arsenović


signature.asc
Description: PGP signature


[PATCH (pushed)] unidiff: use newline='\n' argument

2022-12-11 Thread Martin Liška
In order to support CR on a line, we need to open files
with newline='\n' as our line endings supposed to be of UNIX style.

Pushed to master.

contrib/ChangeLog:

* check_GNU_style.py: Use newline=\n.
* check_GNU_style_lib.py: Simplify.
* gcc-changelog/git_commit.py: Fix issues seen
Rust patchset.
* gcc-changelog/git_email.py: Use newline argument.
* gcc-changelog/test_email.py: New test.
* gcc-changelog/test_patches.txt: New test.
* mklog.py: Use newline argument.
---
 contrib/check_GNU_style.py |  6 +++---
 contrib/check_GNU_style_lib.py |  4 ++--
 contrib/gcc-changelog/git_commit.py| 11 ++-
 contrib/gcc-changelog/git_email.py |  2 +-
 contrib/gcc-changelog/test_email.py|  6 +-
 contrib/gcc-changelog/test_patches.txt | 26 ++
 contrib/mklog.py   |  2 +-
 7 files changed, 44 insertions(+), 13 deletions(-)

diff --git a/contrib/check_GNU_style.py b/contrib/check_GNU_style.py
index 61faa290fa1..969534a3cc9 100755
--- a/contrib/check_GNU_style.py
+++ b/contrib/check_GNU_style.py
@@ -35,9 +35,9 @@ def main():
 format = args.format
 
 if filename == '-':
-check_GNU_style_file(sys.stdin, None, format)
+check_GNU_style_file(sys.stdin, format)
 else:
-with open(filename, 'rb') as diff_file:
-check_GNU_style_file(diff_file, 'utf-8', format)
+with open(filename, newline='\n') as diff_file:
+check_GNU_style_file(diff_file, format)
 
 main()
diff --git a/contrib/check_GNU_style_lib.py b/contrib/check_GNU_style_lib.py
index b5ab67ed285..b3db4fbddc9 100755
--- a/contrib/check_GNU_style_lib.py
+++ b/contrib/check_GNU_style_lib.py
@@ -262,7 +262,7 @@ class SpacesAndTabsMixedTest(unittest.TestCase):
 r = self.check.check('foo', 123, '\t  a = 123;')
 self.assertIsNone(r)
 
-def check_GNU_style_file(file, file_encoding, format):
+def check_GNU_style_file(file, format):
 checks = [LineLengthCheck(), SpacesCheck(), TrailingWhitespaceCheck(),
 SentenceSeparatorCheck(), SentenceEndOfCommentCheck(),
 SentenceDotEndCheck(), FunctionParenthesisCheck(),
@@ -271,7 +271,7 @@ def check_GNU_style_file(file, file_encoding, format):
 SpacesAndTabsMixedCheck()]
 errors = []
 
-patch = PatchSet(file, encoding=file_encoding)
+patch = PatchSet(file)
 
 for pfile in patch.added_files + patch.modified_files:
 t = pfile.target_file.lstrip('b/')
diff --git a/contrib/gcc-changelog/git_commit.py 
b/contrib/gcc-changelog/git_commit.py
index aae3416e082..d90e6c19b76 100755
--- a/contrib/gcc-changelog/git_commit.py
+++ b/contrib/gcc-changelog/git_commit.py
@@ -718,11 +718,12 @@ class GitCommit:
 if not prs:
 # if all ChangeLog entries have identical PRs
 # then use them
-prs = self.changelog_entries[0].prs
-for entry in self.changelog_entries:
-if entry.prs != prs:
-prs = []
-break
+if self.changelog_entries:
+prs = self.changelog_entries[0].prs
+for entry in self.changelog_entries:
+if entry.prs != prs:
+prs = []
+break
 entry = ChangeLogEntry(changelog_location,
self.top_level_authors,
prs)
diff --git a/contrib/gcc-changelog/git_email.py 
b/contrib/gcc-changelog/git_email.py
index 87b419cae5d..2566d4149e7 100755
--- a/contrib/gcc-changelog/git_email.py
+++ b/contrib/gcc-changelog/git_email.py
@@ -37,7 +37,7 @@ unidiff_supports_renaming = hasattr(PatchedFile(), 
'is_rename')
 class GitEmail(GitCommit):
 def __init__(self, filename):
 self.filename = filename
-diff = PatchSet.from_filename(filename)
+diff = PatchSet.from_filename(filename, newline='\n')
 date = None
 author = None
 subject = ''
diff --git a/contrib/gcc-changelog/test_email.py 
b/contrib/gcc-changelog/test_email.py
index d0de88cf562..b9d0cb4157c 100755
--- a/contrib/gcc-changelog/test_email.py
+++ b/contrib/gcc-changelog/test_email.py
@@ -44,7 +44,7 @@ class TestGccChangelog(unittest.TestCase):
 
 filename = None
 patch_lines = []
-with open(os.path.join(script_path, 'test_patches.txt')) as f:
+with open(os.path.join(script_path, 'test_patches.txt'), newline='\n') 
as f:
 lines = f.read()
 for line in lines.split('\n'):
 if line.startswith('==='):
@@ -455,3 +455,7 @@ class TestGccChangelog(unittest.TestCase):
 def test_space_af

Re: [PATCH] Fortran: fix ICE on bad use of statement function [PR107995]

2022-12-11 Thread Jerry D via Gcc-patches

On 12/10/22 1:23 PM, Harald Anlauf via Fortran wrote:

Dear all,

I'm submitting the attached patch on behalf of Steve.
It fixes an ICE that occurs on an obscure use of a
statement function as argument to that function.

Regtested on x86_64-pc-linux-gnu.  OK for mainline?

Thanks,
Harald



OK, looks good. See my unrelated question on mattermost.

Jerry


[committed] d: Fix internal compiler error: in visit, at d/imports.cc:72 (PR108050)

2022-12-11 Thread Iain Buclaw via Gcc-patches
Hi,

This patch fixes an ICE in the D front-end when importing symbols that
have multiple overloads.

The visitor for lowering IMPORTED_DECLs did not have an override for
dealing with importing OverloadSet symbols.  This has now been
implemented in the code generator.

Bootstrapped and regression tested on x86_64-linux-gnu/-m32/-mx32,
committed to mainline, and backported to the release branches for
gcc-10, gcc-11, and gcc-12.

Regards,
Iain.

---
PR d/108050

gcc/d/ChangeLog:

* decl.cc (DeclVisitor::visit (Import *)): Handle build_import_decl
returning a TREE_LIST.
* imports.cc (ImportVisitor::visit (OverloadSet *)): New override.

gcc/testsuite/ChangeLog:

* gdc.dg/imports/pr108050/mod1.d: New.
* gdc.dg/imports/pr108050/mod2.d: New.
* gdc.dg/imports/pr108050/package.d: New.
* gdc.dg/pr108050.d: New test.
---
 gcc/d/decl.cc   | 12 ++--
 gcc/d/imports.cc| 14 ++
 gcc/testsuite/gdc.dg/imports/pr108050/mod1.d|  2 ++
 gcc/testsuite/gdc.dg/imports/pr108050/mod2.d|  2 ++
 gcc/testsuite/gdc.dg/imports/pr108050/package.d |  2 ++
 gcc/testsuite/gdc.dg/pr108050.d |  4 
 6 files changed, 34 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/gdc.dg/imports/pr108050/mod1.d
 create mode 100644 gcc/testsuite/gdc.dg/imports/pr108050/mod2.d
 create mode 100644 gcc/testsuite/gdc.dg/imports/pr108050/package.d
 create mode 100644 gcc/testsuite/gdc.dg/pr108050.d

diff --git a/gcc/d/decl.cc b/gcc/d/decl.cc
index dcfca648e44..bed16323fec 100644
--- a/gcc/d/decl.cc
+++ b/gcc/d/decl.cc
@@ -198,8 +198,16 @@ public:
tree name = (alias != NULL)
  ? get_identifier (alias->toChars ()) : NULL_TREE;
 
-   debug_hooks->imported_module_or_decl (decl, name, context,
- false, false);
+   if (TREE_CODE (decl) != TREE_LIST)
+ debug_hooks->imported_module_or_decl (decl, name, context,
+   false, false);
+   else
+ {
+   /* Overload sets return a list of imported decls.  */
+   for (; decl != NULL_TREE; decl = TREE_CHAIN (decl))
+ debug_hooks->imported_module_or_decl (TREE_VALUE (decl), name,
+   context, false, false);
+ }
  }
   }
 else
diff --git a/gcc/d/imports.cc b/gcc/d/imports.cc
index 133d93d4961..2d331f46c35 100644
--- a/gcc/d/imports.cc
+++ b/gcc/d/imports.cc
@@ -160,6 +160,20 @@ public:
   d->aliassym->accept (this);
   }
 
+  /* Build IMPORTED_DECLs for all overloads in a set.  */
+  void visit (OverloadSet *d) final override
+  {
+vec *tset = NULL;
+
+vec_alloc (tset, d->a.length);
+
+for (size_t i = 0; i < d->a.length; i++)
+  vec_safe_push (tset, build_import_decl (d->a[i]));
+
+this->result_ = build_tree_list_vec (tset);
+tset->truncate (0);
+  }
+
   /* Function aliases are the same as alias symbols.  */
   void visit (FuncAliasDeclaration *d) final override
   {
diff --git a/gcc/testsuite/gdc.dg/imports/pr108050/mod1.d 
b/gcc/testsuite/gdc.dg/imports/pr108050/mod1.d
new file mode 100644
index 000..f27a13dc051
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/imports/pr108050/mod1.d
@@ -0,0 +1,2 @@
+module imports.pr108050.mod1;
+string[] split() { return null; }
diff --git a/gcc/testsuite/gdc.dg/imports/pr108050/mod2.d 
b/gcc/testsuite/gdc.dg/imports/pr108050/mod2.d
new file mode 100644
index 000..29d8aa8f53e
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/imports/pr108050/mod2.d
@@ -0,0 +1,2 @@
+module imports.pr108050.mod2;
+string[] split() { return null; }
diff --git a/gcc/testsuite/gdc.dg/imports/pr108050/package.d 
b/gcc/testsuite/gdc.dg/imports/pr108050/package.d
new file mode 100644
index 000..b8b03b832af
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/imports/pr108050/package.d
@@ -0,0 +1,2 @@
+module imports.pr108050;
+public import imports.pr108050.mod1, imports.pr108050.mod2;
diff --git a/gcc/testsuite/gdc.dg/pr108050.d b/gcc/testsuite/gdc.dg/pr108050.d
new file mode 100644
index 000..69134e73137
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/pr108050.d
@@ -0,0 +1,4 @@
+// { dg-do compile }
+// { dg-additional-sources "imports/pr108050/package.d imports/pr108050/mod1.d 
imports/pr108050/mod2.d" }
+// { dg-options "-g" }
+import imports.pr108050 : split;
-- 
2.37.2



[GCC-12][committed] d: Remove "final" and "override" from visitor method.

2022-12-11 Thread Iain Buclaw via Gcc-patches
Hi,

This patch removes "final" and "override" from the OverloadSet visitor
method.  This was added by the backport of an ICE in r12-8969.  While
harmless, it was not until r13-758 that "final" and "override" were
introduced to all visitor methods in the D front-end.  Removing it from
the release branch just for consistency with the rest of the file.

Committed to releases/gcc-12.

Regards,
Iain.

---
gcc/d/ChangeLog:

* imports.cc (ImportVisitor::visit (OverloadSet *)): Remove "final"
and "override" from visitor method.
---
 gcc/d/imports.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/d/imports.cc b/gcc/d/imports.cc
index 4ce6f026b29..dfda2401ee8 100644
--- a/gcc/d/imports.cc
+++ b/gcc/d/imports.cc
@@ -161,7 +161,7 @@ public:
   }
 
   /* Build IMPORTED_DECLs for all overloads in a set.  */
-  void visit (OverloadSet *d) final override
+  void visit (OverloadSet *d)
   {
 vec *tset = NULL;
 
-- 
2.37.2



[PATCH] Fortran: improve checking of assumed size array spec [PR102180]

2022-12-11 Thread Harald Anlauf via Gcc-patches
Dear all,

the attached patch improves checking of array specs in two ways:
- bad assumed size array spec
- a bad first array element spec may already trigger an error,
  leading to a more consistent behavior

Regtested on x86_64-pc-linux-gnu.  OK for mainline?

Thanks,
Harald

From 06c1d0a96544640c7b1485fe977337ef1572ac91 Mon Sep 17 00:00:00 2001
From: Harald Anlauf 
Date: Sun, 11 Dec 2022 23:24:03 +0100
Subject: [PATCH] Fortran: improve checking of assumed size array spec
 [PR102180]

gcc/fortran/ChangeLog:

	PR fortran/102180
	* array.cc (match_array_element_spec): Add check for bad
	assumed-implied-spec.
	(gfc_match_array_spec): Reorder logic so that a first bad array
	element spec may trigger an error.

gcc/testsuite/ChangeLog:

	PR fortran/102180
	* gfortran.dg/pr102180.f90: New test.
---
 gcc/fortran/array.cc   | 12 ++--
 gcc/testsuite/gfortran.dg/pr102180.f90 | 19 +++
 2 files changed, 29 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/gfortran.dg/pr102180.f90

diff --git a/gcc/fortran/array.cc b/gcc/fortran/array.cc
index bbdb5b392fc..9c1d55fa8cc 100644
--- a/gcc/fortran/array.cc
+++ b/gcc/fortran/array.cc
@@ -488,6 +488,14 @@ match_array_element_spec (gfc_array_spec *as)
   return AS_ASSUMED_SIZE;
 }

+  /* F2018:R821: "assumed-implied-spec  is  [ lower-bound : ] *".  */
+  if (gfc_match (" : * ") == MATCH_YES)
+{
+  gfc_error ("A lower bound must precede colon in "
+		 "assumed size array specification at %C");
+  return AS_UNKNOWN;
+}
+
   if (gfc_match_char (':') == MATCH_YES)
 return AS_DEFERRED;

@@ -591,6 +599,8 @@ gfc_match_array_spec (gfc_array_spec **asp, bool match_dim, bool match_codim)
 {
   as->rank++;
   current_type = match_array_element_spec (as);
+  if (current_type == AS_UNKNOWN)
+	goto cleanup;

   /* Note that current_type == AS_ASSUMED_SIZE for both assumed-size
 	 and implied-shape specifications.  If the rank is at least 2, we can
@@ -600,8 +610,6 @@ gfc_match_array_spec (gfc_array_spec **asp, bool match_dim, bool match_codim)

   if (as->rank == 1)
 	{
-	  if (current_type == AS_UNKNOWN)
-	goto cleanup;
 	  as->type = current_type;
 	}
   else
diff --git a/gcc/testsuite/gfortran.dg/pr102180.f90 b/gcc/testsuite/gfortran.dg/pr102180.f90
new file mode 100644
index 000..cbf3e7299e7
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr102180.f90
@@ -0,0 +1,19 @@
+! { dg-do compile }
+! { dg-options "-fcoarray=lib" }
+! PR fortran/102180 - Improve checking of assumed size array spec
+
+subroutine s(x,y)
+  real :: x(0:*) ! legal
+  real :: y[0:*] ! legal
+end
+
+subroutine t(x,y)
+  real :: x(:*) ! { dg-error "A lower bound must precede colon" }
+  real :: y[:*] ! { dg-error "A lower bound must precede colon" }
+end
+
+subroutine u(x,y,z)
+  real :: x(2,*)
+  real :: y(2,2:*)
+  real :: z(2,:*) ! { dg-error "A lower bound must precede colon" }
+end
--
2.35.3



Re: [PATCH] Fortran: improve checking of assumed size array spec [PR102180]

2022-12-11 Thread Steve Kargl via Gcc-patches
On Sun, Dec 11, 2022 at 11:33:43PM +0100, Harald Anlauf via Fortran wrote:
> Dear all,
> 
> the attached patch improves checking of array specs in two ways:
> - bad assumed size array spec
> - a bad first array element spec may already trigger an error,
>   leading to a more consistent behavior
> 
> Regtested on x86_64-pc-linux-gnu.  OK for mainline?
> 

OK with minor nit.

> +  /* F2018:R821: "assumed-implied-spec  is  [ lower-bound : ] *".  */
> +  if (gfc_match (" : * ") == MATCH_YES)
> +{
> +  gfc_error ("A lower bound must precede colon in "
> +  "assumed size array specification at %C");

"assumed size" should likely be "assumed-size"

> +  return AS_UNKNOWN;
> +}
> +


-- 
Steve


Re: Java front-end and library patches.

2022-12-11 Thread Zopolis0 via Gcc-patches
I've been looking over the reviews as well as a few things I've
encountered locally, and collected this list:

Unfortunately, I am simply not familiar enough with the gcc tree to
implement patch 16, although there is a slight possibility that I may
be able to do patch 19, and a stronger one that I could do patch 16.
(Although I have been working on patch 19 and 16 for a few months now
and with little success).

I can definitely do patch 53, and am working on that.

While patch 13, 16 and 19 are all sub-par solutions, they are
solutions, and as such implementing better solutions is a lower
priority than fixing the remaining issue, the -dumpbase caused linker
error. I would very much appreciate help in that area specifically, as
once that is solved we'll have a working compiler and library, and
then I can focus on improving the library.

(Patch 13) Re-add flag_evaluation_order, reorder_operands_p, and add
reorder bool argument to tree_swap_operands_p:
Replace with front-end specific function ala flag_strong_eval_order

(Patch 16) gcc: Re-add TYPE_METHODS:
Remove, replace instances of TYPE_METHODS with TYPE_FIELDS in the java frontend

(Patch 19) Revert "Move void_list_node init to common code".
(8ff2a92a0450243e52d3299a13b30f208bafa7e0):
Remove, handle properly in Java frontend.

Breakage caused by 1dedc12d186a110854537e1279b4e6c29f2df35a:
Changes to -dumpbase cause undefined link errors, fix usage of
-dumpbase in gcc/java/jvspec.cc

(Patch 53) classpath: Use modern autotools mkdir -p handling:
Find way to make MKDIR_P propagate to generated copy-vmresources.sh


[PATCH V4 2/2] rs6000: use li;x?oris to build constant

2022-12-11 Thread Jiufu Guo via Gcc-patches
Hi,

For constant C:
If '(c & 0xULL) == 0x' or say:
32(1) || 1(0) || 15(x) || 16(0), we could use "lis; xoris" to build.

Here N(M) means N continuous bit M, x for M means it is ok for either
1 or 0; '||' means concatenation.

This patch update rs6000_emit_set_long_const to support those constants.

Compare with previous version:
https://gcc.gnu.org/pipermail/gcc-patches/2022-December/607618.htm
This patch fix conflicts with trunk.

Bootstrap and regtest pass on ppc64{,le}.

Is this ok for trunk?

BR,
Jeff (Jiufu)


PR target/106708

gcc/ChangeLog:

* config/rs6000/rs6000.cc (rs6000_emit_set_long_const): Add to build
constants through "lis; xoris".

gcc/testsuite/ChangeLog:

* gcc.target/powerpc/pr106708.c: Add test function.

---
 gcc/config/rs6000/rs6000.cc |  7 +++
 gcc/testsuite/gcc.target/powerpc/pr106708.c | 10 +-
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc
index 8c1192a10c8..1138d5e8cd4 100644
--- a/gcc/config/rs6000/rs6000.cc
+++ b/gcc/config/rs6000/rs6000.cc
@@ -10251,6 +10251,13 @@ rs6000_emit_set_long_const (rtx dest, HOST_WIDE_INT c)
   if (ud1 != 0)
emit_move_insn (dest, gen_rtx_IOR (DImode, temp, GEN_INT (ud1)));
 }
+  else if (ud4 == 0x && ud3 == 0x && !(ud2 & 0x8000) && ud1 == 0)
+{
+  /* lis; xoris */
+  temp = !can_create_pseudo_p () ? dest : gen_reg_rtx (DImode);
+  emit_move_insn (temp, GEN_INT (sext_hwi ((ud2 | 0x8000) << 16, 32)));
+  emit_move_insn (dest, gen_rtx_XOR (DImode, temp, GEN_INT (0x8000)));
+}
   else if (ud4 == 0x && ud3 == 0x && (ud1 & 0x8000))
 {
   /* li; xoris */
diff --git a/gcc/testsuite/gcc.target/powerpc/pr106708.c 
b/gcc/testsuite/gcc.target/powerpc/pr106708.c
index dc9ceda8367..a015c71e630 100644
--- a/gcc/testsuite/gcc.target/powerpc/pr106708.c
+++ b/gcc/testsuite/gcc.target/powerpc/pr106708.c
@@ -4,7 +4,7 @@
 /* { dg-require-effective-target has_arch_ppc64 } */
 
 long long arr[]
-  = {0x7cdeab55LL, 0x98765432LL, 0xabcdLL};
+= {0x7cdeab55LL, 0x98765432LL, 0xabcdLL, 0x6543LL};
 
 void __attribute__ ((__noipa__)) lixoris (long long *arg)
 {
@@ -27,6 +27,13 @@ void __attribute__ ((__noipa__)) lisrldicl (long long *arg)
 /* { dg-final { scan-assembler-times {\mlis .*,0xabcd\M} 1 } } */
 /* { dg-final { scan-assembler-times {\mrldicl .*,0,32\M} 1 } } */
 
+void __attribute__ ((__noipa__)) lisxoris (long long *arg)
+{
+  *arg = 0x6543LL;
+}
+/* { dg-final { scan-assembler-times {\mlis .*,0xe543\M} 1 } } */
+/* { dg-final { scan-assembler-times {\mxoris .*0x8000\M} 1 } } */
+
 int
 main ()
 {
@@ -35,6 +42,7 @@ main ()
   lixoris (a);
   lioris (a + 1);
   lisrldicl (a + 2);
+  lisxoris (a + 3);
   if (__builtin_memcmp (a, arr, sizeof (arr)) != 0)
 __builtin_abort ();
   return 0;
-- 
2.17.1



[PATCH V4 1/2] rs6000: use li;x?oris to build constant

2022-12-11 Thread Jiufu Guo via Gcc-patches
Hi,

For constant C:
If '(c & 0x8000ULL) == 0x8000ULL' or say:
32(1) || 16(x) || 1(1) || 15(x), using "li; xoris" would be ok.

If '(c & 0x80008000ULL) == 0x8000ULL' or say:
32(0) || 1(1) || 15(x) || 1(0) || 15(x), we could use "li; oris" to
build constant 'C'.

Here N(M) means N continuous bit M, x for M means it is ok for either
1 or 0; '||' means concatenation.

This patch update rs6000_emit_set_long_const to support those constants.

Compare with previous version, this patch fixes conflicts with trunk.
and put li;x?oris as the first patch (lis;xoris as the second patch).
Previous version:
https://gcc.gnu.org/pipermail/gcc-patches/2022-December/607618.html

Bootstrap and regtest pass on ppc64{,le}.

Is this ok for trunk?

BR,
Jeff (Jiufu)


PR target/106708

gcc/ChangeLog:

* config/rs6000/rs6000.cc (rs6000_emit_set_long_const): Add using
"li; x?oris" to build constant.

gcc/testsuite/ChangeLog:

* gcc.target/powerpc/pr106708.c: New test.

---
 gcc/config/rs6000/rs6000.cc | 36 +++---
 gcc/testsuite/gcc.target/powerpc/pr106708.c | 41 +
 2 files changed, 71 insertions(+), 6 deletions(-)
 create mode 100644 gcc/testsuite/gcc.target/powerpc/pr106708.c

diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc
index b3a609f3aa3..8c1192a10c8 100644
--- a/gcc/config/rs6000/rs6000.cc
+++ b/gcc/config/rs6000/rs6000.cc
@@ -10251,17 +10251,41 @@ rs6000_emit_set_long_const (rtx dest, HOST_WIDE_INT c)
   if (ud1 != 0)
emit_move_insn (dest, gen_rtx_IOR (DImode, temp, GEN_INT (ud1)));
 }
+  else if (ud4 == 0x && ud3 == 0x && (ud1 & 0x8000))
+{
+  /* li; xoris */
+  temp = !can_create_pseudo_p () ? dest : gen_reg_rtx (DImode);
+  emit_move_insn (temp, GEN_INT (sext_hwi (ud1, 16)));
+  emit_move_insn (dest, gen_rtx_XOR (DImode, temp,
+GEN_INT ((ud2 ^ 0x) << 16)));
+}
   else if (ud3 == 0 && ud4 == 0)
 {
   temp = !can_create_pseudo_p () ? dest : gen_reg_rtx (DImode);
 
   gcc_assert (ud2 & 0x8000);
-  emit_move_insn (temp, GEN_INT (sext_hwi (ud2 << 16, 32)));
-  if (ud1 != 0)
-   emit_move_insn (temp, gen_rtx_IOR (DImode, temp, GEN_INT (ud1)));
-  emit_move_insn (dest,
- gen_rtx_ZERO_EXTEND (DImode,
-  gen_lowpart (SImode,temp)));
+
+  if (ud1 == 0)
+   {
+ /* lis; rldicl */
+ emit_move_insn (temp, GEN_INT (sext_hwi (ud2 << 16, 32)));
+ emit_move_insn (dest,
+ gen_rtx_AND (DImode, temp, GEN_INT (0x)));
+   }
+  else if (!(ud1 & 0x8000))
+   {
+ /* li; oris */
+ emit_move_insn (temp, GEN_INT (ud1));
+ emit_move_insn (dest,
+ gen_rtx_IOR (DImode, temp, GEN_INT (ud2 << 16)));
+   }
+  else
+   {
+ emit_move_insn (temp, GEN_INT (sext_hwi (ud2 << 16, 32)));
+ emit_move_insn (temp, gen_rtx_IOR (DImode, temp, GEN_INT (ud1)));
+ emit_move_insn (dest,
+ gen_rtx_AND (DImode, temp, GEN_INT (0x)));
+   }
 }
   else if (ud1 == ud3 && ud2 == ud4)
 {
diff --git a/gcc/testsuite/gcc.target/powerpc/pr106708.c 
b/gcc/testsuite/gcc.target/powerpc/pr106708.c
new file mode 100644
index 000..dc9ceda8367
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr106708.c
@@ -0,0 +1,41 @@
+/* PR target/106708 */
+/* { dg-do run } */
+/* { dg-options "-O2 -mno-prefixed -save-temps" } */
+/* { dg-require-effective-target has_arch_ppc64 } */
+
+long long arr[]
+  = {0x7cdeab55LL, 0x98765432LL, 0xabcdLL};
+
+void __attribute__ ((__noipa__)) lixoris (long long *arg)
+{
+  *arg = 0x7cdeab55LL;
+}
+/* { dg-final { scan-assembler-times {\mli .*,-21675\M} 1 } } */
+/* { dg-final { scan-assembler-times {\mxoris .*0x8321\M} 1 } } */
+
+void __attribute__ ((__noipa__)) lioris (long long *arg)
+{
+  *arg = 0x98765432LL;
+}
+/* { dg-final { scan-assembler-times {\mli .*,21554\M} 1 } } */
+/* { dg-final { scan-assembler-times {\moris .*0x9876\M} 1 } } */
+
+void __attribute__ ((__noipa__)) lisrldicl (long long *arg)
+{
+  *arg = 0xabcdLL;
+}
+/* { dg-final { scan-assembler-times {\mlis .*,0xabcd\M} 1 } } */
+/* { dg-final { scan-assembler-times {\mrldicl .*,0,32\M} 1 } } */
+
+int
+main ()
+{
+  long long a[sizeof (arr) / sizeof (arr[0])];
+
+  lixoris (a);
+  lioris (a + 1);
+  lisrldicl (a + 2);
+  if (__builtin_memcmp (a, arr, sizeof (arr)) != 0)
+__builtin_abort ();
+  return 0;
+}
-- 
2.17.1



[PATCH V2] rs6000: Load high and low part of 64bit constant independently

2022-12-11 Thread Jiufu Guo via Gcc-patches
Hi,

Compare with previous patch, this patch updates accoding to comments; fixes
conflicts with trunk, and recheck bootstrap®test.
https://gcc.gnu.org/pipermail/gcc-patches/2022-November/607333.html

For a complicate 64bit constant, blow is one instruction-sequence to
build:
lis 9,0x800a
ori 9,9,0xabcd
sldi 9,9,32
oris 9,9,0xc167
ori 9,9,0xfa16

while we can also use below sequence to build:
lis 9,0xc167
lis 10,0x800a
ori 9,9,0xfa16
ori 10,10,0xabcd
rldimi 9,10,32,0
This sequence is using 2 registers to build high and low part firstly,
and then merge them.

In parallel aspect, this sequence would be faster. (Ofcause, using 1 more
register with potential register pressure).

The instruction sequence with two registers for parallel version can be
generated only if can_create_pseudo_p.  Otherwise, the one register
sequence is generated.

Bootstrap and regtest pass on ppc64{,le}.
Is this ok for trunk?


BR,
Jeff(Jiufu)


gcc/ChangeLog:

* config/rs6000/rs6000.cc (rs6000_emit_set_long_const): Generate
more parallel code if can_create_pseudo_p.

gcc/testsuite/ChangeLog:

* gcc.target/powerpc/parall_5insn_const.c: New test.

---
 gcc/config/rs6000/rs6000.cc   | 37 +--
 .../gcc.target/powerpc/parall_5insn_const.c   | 27 ++
 2 files changed, 52 insertions(+), 12 deletions(-)
 create mode 100644 gcc/testsuite/gcc.target/powerpc/parall_5insn_const.c

diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc
index b3a609f3aa3..3020d9780bc 100644
--- a/gcc/config/rs6000/rs6000.cc
+++ b/gcc/config/rs6000/rs6000.cc
@@ -10322,19 +10322,32 @@ rs6000_emit_set_long_const (rtx dest, HOST_WIDE_INT c)
 }
   else
 {
-  temp = !can_create_pseudo_p () ? dest : gen_reg_rtx (DImode);
-
-  emit_move_insn (temp, GEN_INT (sext_hwi (ud4 << 16, 32)));
-  if (ud3 != 0)
-   emit_move_insn (temp, gen_rtx_IOR (DImode, temp, GEN_INT (ud3)));
+  if (can_create_pseudo_p ())
+   {
+ /* lis H,U4; ori H,U3; lis L,U2; ori L,U1; rldimi L,H,32,0.  */
+ rtx high = gen_reg_rtx (DImode);
+ rtx low = gen_reg_rtx (DImode);
+ HOST_WIDE_INT num = (ud2 << 16) | ud1;
+ rs6000_emit_set_long_const (low, sext_hwi (num, 32));
+ num = (ud4 << 16) | ud3;
+ rs6000_emit_set_long_const (high, sext_hwi (num, 32));
+ emit_insn (gen_rotldi3_insert_3 (dest, high, GEN_INT (32), low,
+  GEN_INT (0x)));
+   }
+  else
+   {
+ /* lis A,U4; ori A,U3; rotl A,32; oris A,U2; ori A,U1.  */
+ emit_move_insn (dest, GEN_INT (sext_hwi (ud4 << 16, 32)));
+ if (ud3 != 0)
+   emit_move_insn (dest, gen_rtx_IOR (DImode, dest, GEN_INT (ud3)));
 
-  emit_move_insn (ud2 != 0 || ud1 != 0 ? temp : dest,
- gen_rtx_ASHIFT (DImode, temp, GEN_INT (32)));
-  if (ud2 != 0)
-   emit_move_insn (ud1 != 0 ? temp : dest,
-   gen_rtx_IOR (DImode, temp, GEN_INT (ud2 << 16)));
-  if (ud1 != 0)
-   emit_move_insn (dest, gen_rtx_IOR (DImode, temp, GEN_INT (ud1)));
+ emit_move_insn (dest, gen_rtx_ASHIFT (DImode, dest, GEN_INT (32)));
+ if (ud2 != 0)
+   emit_move_insn (dest,
+   gen_rtx_IOR (DImode, dest, GEN_INT (ud2 << 16)));
+ if (ud1 != 0)
+   emit_move_insn (dest, gen_rtx_IOR (DImode, dest, GEN_INT (ud1)));
+   }
 }
 }
 
diff --git a/gcc/testsuite/gcc.target/powerpc/parall_5insn_const.c 
b/gcc/testsuite/gcc.target/powerpc/parall_5insn_const.c
new file mode 100644
index 000..e3a9a7264cf
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/parall_5insn_const.c
@@ -0,0 +1,27 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -mno-prefixed -save-temps" } */
+/* { dg-require-effective-target has_arch_ppc64 } */
+
+/* { dg-final { scan-assembler-times {\mlis\M} 4 } } */
+/* { dg-final { scan-assembler-times {\mori\M} 4 } } */
+/* { dg-final { scan-assembler-times {\mrldimi\M} 2 } } */
+
+void __attribute__ ((noinline)) foo (unsigned long long *a)
+{
+  /* 2 lis + 2 ori + 1 rldimi for each constant.  */
+  *a++ = 0x800aabcdc167fa16ULL;
+  *a++ = 0x7543a876867f616ULL;
+}
+
+long long A[] = {0x800aabcdc167fa16ULL, 0x7543a876867f616ULL};
+int
+main ()
+{
+  long long res[2];
+
+  foo (res);
+  if (__builtin_memcmp (res, A, sizeof (res)) != 0)
+__builtin_abort ();
+
+  return 0;
+}
-- 
2.17.1



Re: [PATCH v5, rs6000] Change mode and insn condition for VSX scalar extract/insert instructions

2022-12-11 Thread HAO CHEN GUI via Gcc-patches
Hi Kewen,

在 2022/12/8 16:47, Kewen.Lin 写道:
> This documentation update reminds me of that the current prototype of 
> __ieee128
> variant can be:
> 
>   unsigned int scalar_extract_exp (__ieee128 source);
> 
> type unsigned int is enough for the exponent.  It means xsxexpqp_ can 
> also
> use SImode rather than DImode.


Could I put the changes of __ieee128 bifs in another patch? So, this patch 
doesn't
touch anything about __ieee128.

Thanks a lot
Gui Haochen


Re: [PATCH] libstdc++: Make chrono::hh_mm_ss more compact

2022-12-11 Thread Stephan Bergmann via Gcc-patches

On 11/21/22 21:43, Jonathan Wakely via Libstdc++ wrote:

+   static constexpr bool __is_unsigned
+ = __and_v,
+   is_unsigned>;


Using `__is_unsigned` as an identifier here causes compilation issues 
with Clang, which predefines that as a builtin predicate.




[PATCH] tree-optimization/89317 - another pattern for &p->x != p + 4

2022-12-11 Thread Richard Biener via Gcc-patches
As seen in the original testcase for PR89317 we are missing
comparison simplification patterns for &p->x != p + 4.  Fixed
by making an existing one apply.  To make the pattern apply
during CCP we need to simplify ccp_fold to not use GENERIC
folding of conditions but also use GIMPLE folding.

Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.

PR tree-optimization/89317
* tree-ssa-ccp.cc (ccp_fold): Handle GIMPLE_COND via
gimple_fold_stmt_to_constant_1.
* match.pd (&a != &a + c): Apply to pointer_plus with non-ADDR_EXPR
base as well.

* gcc.dg/tree-ssa/pr89317.c: Amend.
---
 gcc/match.pd|  2 +-
 gcc/testsuite/gcc.dg/tree-ssa/pr89317.c | 17 +
 gcc/tree-ssa-ccp.cc | 11 +--
 3 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/gcc/match.pd b/gcc/match.pd
index ba83c69734f..3517605c04d 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -2263,7 +2263,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
 /* (&a + b) !=/== (&a[1] + c) -> (&a[0] - &a[1]) + b !=/== c */
 (for neeq (ne eq)
  (simplify
-  (neeq:c ADDR_EXPR@0 (pointer_plus ADDR_EXPR@2 @3))
+  (neeq:c ADDR_EXPR@0 (pointer_plus @2 @3))
(with { poly_int64 diff; tree inner_type = TREE_TYPE (@3);}
 (if (ptr_difference_const (@0, @2, &diff))
  (neeq { build_int_cst_type (inner_type, diff); } @3
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr89317.c 
b/gcc/testsuite/gcc.dg/tree-ssa/pr89317.c
index 0d0a049454f..0c8f2f53a45 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/pr89317.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr89317.c
@@ -10,4 +10,21 @@ int foo (struct b *x)
   return b - a;
 }
 
+int bar (struct b *x)
+{
+  int *a = x->data;
+  int *b = ((int*)x) + 4;
+  if (a != b)
+return 1;
+  return 0;
+}
+
+int baz (struct b *x)
+{
+  int *a = x->data;
+  int *b = ((int*)x) + 4;
+  return (a != b);
+}
+
 /* { dg-final { scan-tree-dump "return 4;" "ccp1" } } */
+/* { dg-final { scan-tree-dump-times "return 1;" 2 "ccp1" } } */
diff --git a/gcc/tree-ssa-ccp.cc b/gcc/tree-ssa-ccp.cc
index 69fd7f1d11d..68e69bfe129 100644
--- a/gcc/tree-ssa-ccp.cc
+++ b/gcc/tree-ssa-ccp.cc
@@ -1271,24 +1271,15 @@ valueize_op_1 (tree op)
 static tree
 ccp_fold (gimple *stmt)
 {
-  location_t loc = gimple_location (stmt);
   switch (gimple_code (stmt))
 {
-case GIMPLE_COND:
-  {
-/* Handle comparison operators that can appear in GIMPLE form.  */
-tree op0 = valueize_op (gimple_cond_lhs (stmt));
-tree op1 = valueize_op (gimple_cond_rhs (stmt));
-enum tree_code code = gimple_cond_code (stmt);
-return fold_binary_loc (loc, code, boolean_type_node, op0, op1);
-  }
-
 case GIMPLE_SWITCH:
   {
/* Return the constant switch index.  */
 return valueize_op (gimple_switch_index (as_a  (stmt)));
   }
 
+case GIMPLE_COND:
 case GIMPLE_ASSIGN:
 case GIMPLE_CALL:
   return gimple_fold_stmt_to_constant_1 (stmt,
-- 
2.35.3