[Bug middle-end/109849] suboptimal code for vector walking loop

2023-05-13 Thread amonakov at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109849

Alexander Monakov  changed:

   What|Removed |Added

 CC||amonakov at gcc dot gnu.org

--- Comment #3 from Alexander Monakov  ---
Rather, because store-motion out of a loop that might iterate zero times would
create a data race.

Re: More C type errors by default for GCC 14

2023-05-13 Thread Eli Schwartz via Gcc
On 5/14/23 1:28 AM, Po Lu wrote:
>> GCC has formal documentation. It is written in HTML. If it is lacking,
>> then the only valid move is to improve the HTML documentation and then
>> abide by it. In the absence of documentation, all behavior is, well,
>> "undocumented", which ***definitely*** means it isn't a formal GNUC
>> language dialect extension.
> 
> GCC documentation is written in HTML? That's news to me.  I always
> thought it was written in Texinfo.


Does this mean you've conceded the point, and no longer think it is
written in C++?

:)


>> You can stop arguing your opinions based on what running gcc or g++
>> produces in the form of machine code. What gcc or g++ produces in the
>> form of machine code is not guaranteed even across bugfix releases --
>> your only guarantee is that if it is documented in the ISO standards
>> documents or in the GCC html manual, the produced machine code shall be
>> in accordance with what the documentation says it shall do.
> 
> Generated machine code, really?  Not long-standing and observable
> behavior of the translator itself, as has been re-iterated over and over
> again?


You are correct in reading my sentence, that is indeed what I said.

Aside: you have reiterated "the behavior of the translator itself" over
and over again, but it hasn't been generally reiterated, or even iterated.


>> Undefined and undocumented behavior is not a language extension. It is
>> undefined and undocumented behavior.
> 
> But when it becomes defined by the translator, in a precise way, it
> becomes an extension to the Standard.


Repeating this statement won't make it true.


>> You may feel free to take an exact GCC release (source or binary),
>> analyze it, reverse-engineer it, or verify that it does what you want
>> it to do, and then trust that those undefined and undocumented
>> behaviors are ***benevolent***, but that doesn't cause it to be
>> defined and documented, and your trust will, if you are wise, depend
>> on you pinning an exact source code commit of the compiler. Do not
>> depend on bugfix releases of GCC to preserve your undocumented
>> semantics. They may or they may not, but if they don't, it's not a GCC
>> bug, because it is ***undocumented***.
> 
> GCC does not implement its documentation.  The documentation is supposed
> to describe (_not_ specify) how GCC behaves, and when the documentation
> is wrong or contains omissions, the documentation will have to be fixed.
> Not the compiler itself.
> 
> And it's not just GCC.  Almost all programs work this way.


In fact, lots and lots and lots of programs do indeed operate such that
the documentation specifies how the program shall behave, and when the
program fails to behave in the manner in which it is documented to
behave, the program shall be fixed.

We call these failures to behave according to the documentation,


Bugs.


Occasionally it is also called specification-driven development.

...

In cases where the documentation says nothing at all, for good or ill,
the behavior of the program is undefined -- users cannot rely on it, for
they cannot know what is intended and what is not intended -- in this
case, the intended behavior must be defined, documented, and
implemented, and "the program currently does X" gets one vote out of
many and is not guaranteed to get its way.

Very often in such cases the best user-serving thing to do is to define
the behavior as "shall not be used, and for legacy reasons if you use it
it will continue to do X but raise a warning telling you that you are
required to stop depending on it" and possibly even "it may disappear in
semver version YYY".

Sound familiar? A bit like GCC triggering a warning, telling you that
what you're doing is bad and should not be relied on?

But GCC isn't dropping support for it in semver version anything, just
guarding its use behind an opt-in flag.


-- 
Eli Schwartz


Re: More C type errors by default for GCC 14

2023-05-13 Thread Po Lu via Gcc
Eli Schwartz  writes:

> GNU C does not define any such thing. It may happen to turn out that
> way, but that is not the same as defining its behavior.

It is.

>> Nor does GCC conform to the Standard by default: while it is okay for a
>> conforming implementation to translate programs relying on implicit int,
>> as there is no way doing so will alter the behavior of any strictly
>> conforming program, it is not okay to reserve keywords such as `asm'.
>> 
>> The following strictly conforming program is thus not acceptable to GCC,
>> unless GCC is operating in standards-conformance mode:
>> 
>>   int
>>   main (argc, argv)
>>   int argc;
>>   char **argv;
>>   {
>> int asm;
>> return asm = 0;
>>   }
>> 
>> which shows that debating features based on the Standard is entirely
>> pointless, as the Standard allows implementations to provide almost
>> anything it prohibits.
>
>
> Sure, all I have to do is tell GCC to act like a C compiler.
>
>
> $ gcc -std=c2x /tmp/po.c -o /tmp/po; /tmp/po; echo $?
> /tmp/po.c: In function ‘main’:
> /tmp/po.c:2:3: warning: old-style function definition
> [-Wold-style-definition]
> 2 |   main (argc, argv)
>   |   ^~~~
> 0

No, all you have to do is to tell GNU CC to compile Standard C.  But
what's being debated here is the behavior of GNU CC when translating
both Standard C and GNU C, so your demonstration is almost completely
pointless.

Btw, try to compile any program using inline assembler, and you will
quickly find out how many programs depend on the (gasp!) non-conformant
behavior of GNU C.

> But I don't understand what point you are trying to make, anyway. The
> Standard allows, but does not require, implementations to do many things
> if it so chooses. GNUC takes advantage of this when operating in GNUC
> mode, when also documenting GNUC features in the HTML docs.

[...]

> What does this have to do with implicit-int, which is a constraint
> violation? Where in the GNUC html documentation does it say that
> constraint violations applied to Type specifiers have been carved out as
> a GNUC extension?

As I said, what the Info documentation does not say is completely
irrelevant.  I might as well ask you: where in (gcc)C Extensions is it
said that the documentation describes each and every extension and
aspect of GNU C?

The documentation is supposed to describe the behavior of the
translator, not to specify it.

> It's not a GNUC extension, you cannot assume it will work. It might work
> anyway, but that's a matter of luck.

It _is_, regardless of what you might say.

> It is unclear why you are overly focused on implicit-int, to be honest.

Because there is a point to be made for discouraging implicit function
declarations.  Certainly not enough to make them errors in GNU C, but
enough to justify their obsolescence in the ANSI Standard.

There is none whatsoever for discouraging implicit int.  Its
obsolescence and later removal was simply the act of a overzealous
Committee, deviating too far from its task of standardizing existing
practice.

> But your arguments in favor of implicit-int aren't very compelling either.

Tell me how?


Re: More C type errors by default for GCC 14

2023-05-13 Thread Po Lu via Gcc
Eli Schwartz  writes:

> Quoting my previous reply on the topic.
>
> Until everyone is on the same page as you about whether these are GNUC
> extensions, this conversation will go nowhere.
>
> You are of the opinion that "GCC currently behaves a certain way when
> compiling the code" means that the behavior is documented and specified
> as a "C Extension" for the GNUC language dialect.

Yes, by the definition of ``extension'' used by everyone except you.

> You've provided some excuses like "C++ is a valid language for writing
> documentation in, and the HTML docs are lacking", but your arguments are
> not convincing.
>
> GCC has formal documentation. It is written in HTML. If it is lacking,
> then the only valid move is to improve the HTML documentation and then
> abide by it. In the absence of documentation, all behavior is, well,
> "undocumented", which ***definitely*** means it isn't a formal GNUC
> language dialect extension.

GCC documentation is written in HTML? That's news to me.  I always
thought it was written in Texinfo.

> You can stop arguing your opinions based on what running gcc or g++
> produces in the form of machine code. What gcc or g++ produces in the
> form of machine code is not guaranteed even across bugfix releases --
> your only guarantee is that if it is documented in the ISO standards
> documents or in the GCC html manual, the produced machine code shall be
> in accordance with what the documentation says it shall do.

Generated machine code, really?  Not long-standing and observable
behavior of the translator itself, as has been re-iterated over and over
again?

> Undefined and undocumented behavior is not a language extension. It is
> undefined and undocumented behavior.

But when it becomes defined by the translator, in a precise way, it
becomes an extension to the Standard.

> You may feel free to take an exact GCC release (source or binary),
> analyze it, reverse-engineer it, or verify that it does what you want
> it to do, and then trust that those undefined and undocumented
> behaviors are ***benevolent***, but that doesn't cause it to be
> defined and documented, and your trust will, if you are wise, depend
> on you pinning an exact source code commit of the compiler. Do not
> depend on bugfix releases of GCC to preserve your undocumented
> semantics. They may or they may not, but if they don't, it's not a GCC
> bug, because it is ***undocumented***.

GCC does not implement its documentation.  The documentation is supposed
to describe (_not_ specify) how GCC behaves, and when the documentation
is wrong or contains omissions, the documentation will have to be fixed.
Not the compiler itself.

And it's not just GCC.  Almost all programs work this way.


Re: More C type errors by default for GCC 14

2023-05-13 Thread Eli Schwartz via Gcc
On 5/13/23 1:53 AM, Po Lu wrote:
> There are no ``errors'' in Standard C (with the possible exception of
> the #error preprocessing directive), only constraint and syntax rule
> violations.  Such violations are required to generate diagnostic
> messages, after which the behavior of the translator ceases to be
> defined by the Standard, but GNU C defines it to mean that the type is
> int.


GNU C does not define any such thing. It may happen to turn out that
way, but that is not the same as defining its behavior.


> Nor does GCC conform to the Standard by default: while it is okay for a
> conforming implementation to translate programs relying on implicit int,
> as there is no way doing so will alter the behavior of any strictly
> conforming program, it is not okay to reserve keywords such as `asm'.
> 
> The following strictly conforming program is thus not acceptable to GCC,
> unless GCC is operating in standards-conformance mode:
> 
>   int
>   main (argc, argv)
>   int argc;
>   char **argv;
>   {
> int asm;
> return asm = 0;
>   }
> 
> which shows that debating features based on the Standard is entirely
> pointless, as the Standard allows implementations to provide almost
> anything it prohibits.


Sure, all I have to do is tell GCC to act like a C compiler.


$ gcc -std=c2x /tmp/po.c -o /tmp/po; /tmp/po; echo $?
/tmp/po.c: In function ‘main’:
/tmp/po.c:2:3: warning: old-style function definition
[-Wold-style-definition]
2 |   main (argc, argv)
  |   ^~~~
0


But I don't understand what point you are trying to make, anyway. The
Standard allows, but does not require, implementations to do many things
if it so chooses. GNUC takes advantage of this when operating in GNUC
mode, when also documenting GNUC features in the HTML docs.


What does this have to do with implicit-int, which is a constraint
violation? Where in the GNUC html documentation does it say that
constraint violations applied to Type specifiers have been carved out as
a GNUC extension?

It's not a GNUC extension, you cannot assume it will work. It might work
anyway, but that's a matter of luck.


> So I ask you again: what is unclear about declarations which are
> implicitly int, in a way that is likely to cause program errors?

It is unclear why you are overly focused on implicit-int, to be honest.

But your arguments in favor of implicit-int aren't very compelling either.


-- 
Eli Schwartz


Re: More C type errors by default for GCC 14

2023-05-13 Thread Eli Schwartz via Gcc
On 5/12/23 8:45 PM, Po Lu wrote:
> Gabriel Ravier  writes:
> 
>> ...You're joking, right ? You can't possibly be seriously arguing
>> this, you have to be kidding... right ?
> 
> No, I'm not.  The meaning of a variable declaration with only a storage
> class specifier is extremely clear: the type of the variable is `int'.
> There's absolutely nothing ambiguous about it whatsoever:


Quoting my previous reply on the topic.

Until everyone is on the same page as you about whether these are GNUC
extensions, this conversation will go nowhere.

You are of the opinion that "GCC currently behaves a certain way when
compiling the code" means that the behavior is documented and specified
as a "C Extension" for the GNUC language dialect.

You've provided some excuses like "C++ is a valid language for writing
documentation in, and the HTML docs are lacking", but your arguments are
not convincing.

GCC has formal documentation. It is written in HTML. If it is lacking,
then the only valid move is to improve the HTML documentation and then
abide by it. In the absence of documentation, all behavior is, well,
"undocumented", which ***definitely*** means it isn't a formal GNUC
language dialect extension.

You can stop arguing your opinions based on what running gcc or g++
produces in the form of machine code. What gcc or g++ produces in the
form of machine code is not guaranteed even across bugfix releases --
your only guarantee is that if it is documented in the ISO standards
documents or in the GCC html manual, the produced machine code shall be
in accordance with what the documentation says it shall do.

Undefined and undocumented behavior is not a language extension. It is
undefined and undocumented behavior. You may feel free to take an exact
GCC release (source or binary), analyze it, reverse-engineer it, or
verify that it does what you want it to do, and then trust that those
undefined and undocumented behaviors are ***benevolent***, but that
doesn't cause it to be defined and documented, and your trust will, if
you are wise, depend on you pinning an exact source code commit of the
compiler. Do not depend on bugfix releases of GCC to preserve your
undocumented semantics. They may or they may not, but if they don't,
it's not a GCC bug, because it is ***undocumented***.

...

So in answer to your question, the meaning of such a variable
declaration is very much unclear -- C specifies one thing, GNUC doesn't
specify *anything*, and actually executing the gcc compiler frontend
tool will do... something.


-- 
Eli Schwartz


[Bug tree-optimization/109829] Optimizing __builtin_signbit(x) ? -x : x or abs for FP

2023-05-13 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109829

Andrew Pinski  changed:

   What|Removed |Added

   Keywords||patch
URL||https://gcc.gnu.org/piperma
   ||il/gcc-patches/2023-May/618
   ||435.html

--- Comment #9 from Andrew Pinski  ---
Patch submitted:
https://gcc.gnu.org/pipermail/gcc-patches/2023-May/618435.html

[Bug libfortran/107068] Run-time error when reading logical arrays with a namelist

2023-05-13 Thread jvdelisle at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107068

--- Comment #7 from Jerry DeLisle  ---
In list_read.c we have this comment:

/* To read a logical we have to look ahead in the input stream to make sure
there is not an equal sign indicating a variable name.  To do this we use
line_buffer to point to a temporary buffer, pushing characters there for
possible later reading. */

I remember creating this line_buffer for the purpose. Now to figure out why it
is not working. This was quite a while ago!

[PATCH] MATCH: Add pattern for `signbit(x) ? x : -x` into abs (and swapped)

2023-05-13 Thread Andrew Pinski via Gcc-patches
This adds a simple pattern to match.pd for `signbit(x) ? x : -x`
into abs. This can be done for all types even ones that honor
signed zeros and NaNs because both signbit and - are considered
only looking at/touching the sign bit of those types and does
not trap either.

OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.

PR tree-optimization/109829

gcc/ChangeLog:

* match.pd: Add pattern for `signbit(x) !=/== 0 ? x : -x`.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/abs-3.c: New test.
* gcc.dg/tree-ssa/abs-4.c: New test.
---
 gcc/match.pd  | 10 ++
 gcc/testsuite/gcc.dg/tree-ssa/abs-3.c | 13 +
 gcc/testsuite/gcc.dg/tree-ssa/abs-4.c | 13 +
 3 files changed, 36 insertions(+)
 create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/abs-3.c
 create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/abs-4.c

diff --git a/gcc/match.pd b/gcc/match.pd
index 26395880047..b025fb8facf 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -7439,6 +7439,16 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
&& TREE_CODE (@0) != INTEGER_CST)
(op @0 (ext @1 @2)
 
+/* signbit(x) != 0 ? -x : x -> abs(x)
+   signbit(x) == 0 ? -x : x -> -abs(x) */
+(for sign (SIGNBIT)
+ (for neeq (ne eq)
+  (simplify
+   (cond (neeq (sign @0) integer_zerop) (negate @0) @0)
+(if (neeq == NE_EXPR)
+ (abs @0)
+ (negate (abs @0))
+
 (simplify
  /* signbit(x) -> 0 if x is nonnegative.  */
  (SIGNBIT tree_expr_nonnegative_p@0)
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/abs-3.c 
b/gcc/testsuite/gcc.dg/tree-ssa/abs-3.c
new file mode 100644
index 000..d2638e8f4c5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/abs-3.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-O1 -fdump-tree-optimized" } */
+/* PR tree-optimization/109829 */
+
+float abs_f(float x) { return __builtin_signbit(x) ? -x : x; }
+double abs_d(double x) { return __builtin_signbit(x) ? -x : x; }
+long double abs_ld(long double x) { return __builtin_signbit(x) ? -x : x; }
+
+
+/* __builtin_signbit(x) ? -x : x. Should be convert into ABS_EXP */
+/* { dg-final { scan-tree-dump-not "signbit" "optimized"} } */
+/* { dg-final { scan-tree-dump-not "= -" "optimized"} } */
+/* { dg-final { scan-tree-dump-times "= ABS_EXPR" 3 "optimized"} } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/abs-4.c 
b/gcc/testsuite/gcc.dg/tree-ssa/abs-4.c
new file mode 100644
index 000..6197519faf7
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/abs-4.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-O1 -fdump-tree-optimized" } */
+/* PR tree-optimization/109829 */
+
+float abs_f(float x) { return __builtin_signbit(x) ? x : -x; }
+double abs_d(double x) { return __builtin_signbit(x) ? x : -x; }
+long double abs_ld(long double x) { return __builtin_signbit(x) ? x : -x; }
+
+
+/* __builtin_signbit(x) ? x : -x. Should be convert into - ABS_EXP */
+/* { dg-final { scan-tree-dump-not "signbit" "optimized"} } */
+/* { dg-final { scan-tree-dump-times "= ABS_EXPR" 3 "optimized"} } */
+/* { dg-final { scan-tree-dump-times "= -" 3 "optimized"} } */
-- 
2.31.1



Re: [PATCH 05/14] m2: use _P() defines from tree.h

2023-05-13 Thread Gaius Mulley via Gcc-patches
Bernhard Reutner-Fischer via Gcc-patches 
writes:

> From: Bernhard Reutner-Fischer 
>
> gcc/m2/ChangeLog:
>
>   * gm2-gcc/m2builtins.cc (doradix): Use _P defines from tree.h.
>   (doplaces): Ditto.
>   (doexponentmin): Ditto.
>   (doexponentmax): Ditto.
>   (dolarge): Ditto.
>   (dosmall): Ditto.
>   (dogUnderflow): Ditto.
>   * gm2-gcc/m2convert.cc (unsafe_conversion_p): Ditto.
>   * gm2-gcc/m2expr.cc (m2expr_build_unary_op_check): Ditto.
>   (m2expr_build_binary_op_check): Ditto.
>   * gm2-gcc/m2tree.cc (m2tree_is_var): Ditto.
>   * gm2-gcc/m2treelib.cc (build_modify_expr): Ditto.
>   * gm2-gcc/m2type.cc (gm2_finish_decl): Ditto.
>   * m2pp.cc (hextree): Ditto.
>   (m2pp_call_expr): Ditto.
> ---
>  gcc/m2/gm2-gcc/m2builtins.cc | 14 +++---
>  gcc/m2/gm2-gcc/m2convert.cc  |  8 
>  gcc/m2/gm2-gcc/m2expr.cc |  4 ++--
>  gcc/m2/gm2-gcc/m2tree.cc |  2 +-
>  gcc/m2/gm2-gcc/m2treelib.cc  |  2 +-
>  gcc/m2/gm2-gcc/m2type.cc |  4 ++--
>  gcc/m2/m2pp.cc   |  4 ++--
>  7 files changed, 19 insertions(+), 19 deletions(-)

Hi Bernhard,

from the m2 perspective - lgtm - thanks for the patch!

regards,
Gaius


Re: [PATCH 05/14] m2: use _P() defines from tree.h

2023-05-13 Thread Gaius Mulley via Gcc-patches
Bernhard Reutner-Fischer via Gcc-patches 
writes:

> From: Bernhard Reutner-Fischer 
>
> gcc/m2/ChangeLog:
>
>   * gm2-gcc/m2builtins.cc (doradix): Use _P defines from tree.h.
>   (doplaces): Ditto.
>   (doexponentmin): Ditto.
>   (doexponentmax): Ditto.
>   (dolarge): Ditto.
>   (dosmall): Ditto.
>   (dogUnderflow): Ditto.
>   * gm2-gcc/m2convert.cc (unsafe_conversion_p): Ditto.
>   * gm2-gcc/m2expr.cc (m2expr_build_unary_op_check): Ditto.
>   (m2expr_build_binary_op_check): Ditto.
>   * gm2-gcc/m2tree.cc (m2tree_is_var): Ditto.
>   * gm2-gcc/m2treelib.cc (build_modify_expr): Ditto.
>   * gm2-gcc/m2type.cc (gm2_finish_decl): Ditto.
>   * m2pp.cc (hextree): Ditto.
>   (m2pp_call_expr): Ditto.

Hi Bernhard,

from the m2 perspective - all looks good to me - thanks for the patch,

regards,
Gaius


[Bug libfortran/107068] Run-time error when reading logical arrays with a namelist

2023-05-13 Thread jvdelisle at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107068

--- Comment #6 from Jerry DeLisle  ---
What is happening here is that in the name list input, the variable flp is also
a legal LOGICAL value, so our read is interpreting it as the second value of
the array flc and trying to continue to read values for flc. It encounters the
( and throws the error.

To resolve this, I think I will have to check for a valid variable name for
each value.

[aside: A lot of these issues stem from the weaknesses in how namelists are
interpreted.  There are ambiguities in the specification.]

My next step here is to go through the F2018 standard just to make sure what we
do is valid or invalid. (cheers)

[PATCH 06/14] lto: use _P() defines from tree.h

2023-05-13 Thread Bernhard Reutner-Fischer via Gcc-patches
From: Bernhard Reutner-Fischer 

gcc/ChangeLog:

* lto-streamer-in.cc (lto_input_var_decl_ref): Use _P defines from
tree.h.
(lto_read_body_or_constructor): Ditto.
* lto-streamer-out.cc (tree_is_indexable): Ditto.
(lto_output_var_decl_ref): Ditto.
(DFS::DFS_write_tree_body): Ditto.
(wrap_refs): Ditto.
(write_symbol_extension_info): Ditto.

gcc/lto/ChangeLog:

* lto-common.cc (lto_maybe_register_decl):
* lto-symtab.cc (warn_type_compatibility_p):
(lto_symtab_resolve_replaceable_p):
(lto_symtab_merge_decls_1):
* lto-symtab.h (lto_symtab_prevailing_decl):
---
 gcc/lto-streamer-in.cc  |  4 ++--
 gcc/lto-streamer-out.cc | 11 +--
 gcc/lto/lto-common.cc   |  2 +-
 gcc/lto/lto-symtab.cc   |  8 
 gcc/lto/lto-symtab.h|  2 +-
 5 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/gcc/lto-streamer-in.cc b/gcc/lto-streamer-in.cc
index 03cb41cfa16..2cb83406db5 100644
--- a/gcc/lto-streamer-in.cc
+++ b/gcc/lto-streamer-in.cc
@@ -671,7 +671,7 @@ lto_input_var_decl_ref (lto_input_block *ib, 
lto_file_decl_data *file_data)
   unsigned int ix_u = streamer_read_uhwi (ib);
   tree result = (*file_data->current_decl_state
 ->streams[LTO_DECL_STREAM])[ix_u];
-  gcc_assert (TREE_CODE (result) == VAR_DECL);
+  gcc_assert (VAR_P (result));
   return result;
 }
 
@@ -1653,7 +1653,7 @@ lto_read_body_or_constructor (struct lto_file_decl_data 
*file_data, struct symta
 
  if (TYPE_P (t))
{
- gcc_assert (TYPE_CANONICAL (t) == NULL_TREE);
+ gcc_assert (TYPE_STRUCTURAL_EQUALITY_P (t));
  if (type_with_alias_set_p (t)
  && canonical_type_used_p (t))
TYPE_CANONICAL (t) = TYPE_MAIN_VARIANT (t);
diff --git a/gcc/lto-streamer-out.cc b/gcc/lto-streamer-out.cc
index 0bca530313c..5ab2eb4301e 100644
--- a/gcc/lto-streamer-out.cc
+++ b/gcc/lto-streamer-out.cc
@@ -178,7 +178,7 @@ tree_is_indexable (tree t)
   && lto_variably_modified_type_p (DECL_CONTEXT (t)))
 return false;
   else
-return (TYPE_P (t) || DECL_P (t) || TREE_CODE (t) == SSA_NAME);
+return (IS_TYPE_OR_DECL_P (t) || TREE_CODE (t) == SSA_NAME);
 }
 
 
@@ -346,7 +346,7 @@ void
 lto_output_var_decl_ref (struct lto_out_decl_state *decl_state,
 struct lto_output_stream * obs, tree decl)
 {
-  gcc_checking_assert (TREE_CODE (decl) == VAR_DECL);
+  gcc_checking_assert (VAR_P (decl));
   streamer_write_uhwi_stream
  (obs, lto_get_index (_state->streams[LTO_DECL_STREAM],
  decl));
@@ -1078,8 +1078,7 @@ DFS::DFS_write_tree_body (struct output_block *ob,
   else if (RECORD_OR_UNION_TYPE_P (expr))
for (tree t = TYPE_FIELDS (expr); t; t = TREE_CHAIN (t))
  DFS_follow_tree_edge (t);
-  else if (TREE_CODE (expr) == FUNCTION_TYPE
-  || TREE_CODE (expr) == METHOD_TYPE)
+  else if (FUNC_OR_METHOD_TYPE_P (expr))
DFS_follow_tree_edge (TYPE_ARG_TYPES (expr));
 
   if (!POINTER_TYPE_P (expr))
@@ -2626,7 +2625,7 @@ wrap_refs (tree *tp, int *ws, void *)
 {
   tree t = *tp;
   if (handled_component_p (t)
-  && TREE_CODE (TREE_OPERAND (t, 0)) == VAR_DECL
+  && VAR_P (TREE_OPERAND (t, 0))
   && TREE_PUBLIC (TREE_OPERAND (t, 0)))
 {
   tree decl = TREE_OPERAND (t, 0);
@@ -3064,7 +3063,7 @@ write_symbol_extension_info (tree t)
? GCCST_VARIABLE : GCCST_FUNCTION);
   lto_write_data (, 1);
   unsigned char section_kind = 0;
-  if (TREE_CODE (t) == VAR_DECL)
+  if (VAR_P (t))
 {
   section *s = get_variable_section (t, false);
   if (s->common.flags & SECTION_BSS)
diff --git a/gcc/lto/lto-common.cc b/gcc/lto/lto-common.cc
index 882dd8971a4..537570204b3 100644
--- a/gcc/lto/lto-common.cc
+++ b/gcc/lto/lto-common.cc
@@ -958,7 +958,7 @@ lto_register_function_decl_in_symtab (class data_in 
*data_in, tree decl,
 static void
 lto_maybe_register_decl (class data_in *data_in, tree t, unsigned ix)
 {
-  if (TREE_CODE (t) == VAR_DECL)
+  if (VAR_P (t))
 lto_register_var_decl_in_symtab (data_in, t, ix);
   else if (TREE_CODE (t) == FUNCTION_DECL
   && !fndecl_built_in_p (t))
diff --git a/gcc/lto/lto-symtab.cc b/gcc/lto/lto-symtab.cc
index 2b57d0d5371..79ba8ddde20 100644
--- a/gcc/lto/lto-symtab.cc
+++ b/gcc/lto/lto-symtab.cc
@@ -214,7 +214,7 @@ warn_type_compatibility_p (tree prevailing_type, tree type,
 
   /* Function types needs special care, because types_compatible_p never
  thinks prototype is compatible to non-prototype.  */
-  if (TREE_CODE (type) == FUNCTION_TYPE || TREE_CODE (type) == METHOD_TYPE)
+  if (FUNC_OR_METHOD_TYPE_P (type))
 {
   if (TREE_CODE (type) != TREE_CODE (prevailing_type))
lev |= 1;
@@ -401,7 +401,7 @@ lto_symtab_resolve_replaceable_p (symtab_node *e)
   || DECL_WEAK (e->decl))
 return true;
 
-  if (TREE_CODE (e->decl) == VAR_DECL)
+  if 

[PATCH 14/14] gcc: use _P() defines from tree.h

2023-05-13 Thread Bernhard Reutner-Fischer via Gcc-patches
From: Bernhard Reutner-Fischer 

gcc/ChangeLog:

* alias.cc (ref_all_alias_ptr_type_p): Use _P() defines from tree.h.
* attribs.cc (diag_attr_exclusions): Ditto.
(decl_attributes): Ditto.
(build_type_attribute_qual_variant): Ditto.
* builtins.cc (fold_builtin_carg): Ditto.
(fold_builtin_next_arg): Ditto.
(do_mpc_arg2): Ditto.
* cfgexpand.cc (expand_return): Ditto.
* cgraph.h (decl_in_symtab_p): Ditto.
(symtab_node::get_create): Ditto.
* dwarf2out.cc (base_type_die): Ditto.
(implicit_ptr_descriptor): Ditto.
(gen_array_type_die): Ditto.
(gen_type_die_with_usage): Ditto.
(optimize_location_into_implicit_ptr): Ditto.
* expr.cc (do_store_flag): Ditto.
* fold-const.cc (negate_expr_p): Ditto.
(fold_negate_expr_1): Ditto.
(fold_convert_const): Ditto.
(fold_convert_loc): Ditto.
(constant_boolean_node): Ditto.
(fold_binary_op_with_conditional_arg): Ditto.
(build_fold_addr_expr_with_type_loc): Ditto.
(fold_comparison): Ditto.
(fold_checksum_tree): Ditto.
(tree_unary_nonnegative_warnv_p): Ditto.
(integer_valued_real_unary_p): Ditto.
(fold_read_from_constant_string): Ditto.
* gcc-rich-location.cc 
(maybe_range_label_for_tree_type_mismatch::get_text): Ditto.
* gimple-expr.cc (useless_type_conversion_p): Ditto.
(is_gimple_reg): Ditto.
(is_gimple_asm_val): Ditto.
(mark_addressable): Ditto.
* gimple-expr.h (is_gimple_variable): Ditto.
(virtual_operand_p): Ditto.
* gimple-ssa-warn-access.cc (pass_waccess::check_dangling_stores): 
Ditto.
* gimplify.cc (gimplify_bind_expr): Ditto.
(gimplify_return_expr): Ditto.
(gimple_add_padding_init_for_auto_var): Ditto.
(gimplify_addr_expr): Ditto.
(omp_add_variable): Ditto.
(omp_notice_variable): Ditto.
(omp_get_base_pointer): Ditto.
(omp_strip_components_and_deref): Ditto.
(omp_strip_indirections): Ditto.
(omp_accumulate_sibling_list): Ditto.
(omp_build_struct_sibling_lists): Ditto.
(gimplify_adjust_omp_clauses_1): Ditto.
(gimplify_adjust_omp_clauses): Ditto.
(gimplify_omp_for): Ditto.
(goa_lhs_expr_p): Ditto.
(gimplify_one_sizepos): Ditto.
* graphite-scop-detection.cc 
(scop_detection::graphite_can_represent_scev): Ditto.
* ipa-devirt.cc (odr_types_equivalent_p): Ditto.
* ipa-prop.cc (ipa_set_jf_constant): Ditto.
(propagate_controlled_uses): Ditto.
* ipa-sra.cc (type_prevails_p): Ditto.
(scan_expr_access): Ditto.
* optabs-tree.cc (optab_for_tree_code): Ditto.
* toplev.cc (wrapup_global_declaration_1): Ditto.
* trans-mem.cc (transaction_invariant_address_p): Ditto.
* tree-cfg.cc (verify_types_in_gimple_reference): Ditto.
(verify_gimple_comparison): Ditto.
(verify_gimple_assign_binary): Ditto.
(verify_gimple_assign_single): Ditto.
* tree-complex.cc (get_component_ssa_name): Ditto.
* tree-emutls.cc (lower_emutls_2): Ditto.
* tree-inline.cc (copy_tree_body_r): Ditto.
(estimate_move_cost): Ditto.
(copy_decl_for_dup_finish): Ditto.
* tree-nested.cc (convert_nonlocal_omp_clauses): Ditto.
(note_nonlocal_vla_type): Ditto.
(convert_local_omp_clauses): Ditto.
(remap_vla_decls): Ditto.
(fixup_vla_decls): Ditto.
* tree-parloops.cc (loop_has_vector_phi_nodes): Ditto.
* tree-pretty-print.cc (print_declaration): Ditto.
(print_call_name): Ditto.
* tree-sra.cc (compare_access_positions): Ditto.
* tree-ssa-alias.cc (compare_type_sizes): Ditto.
* tree-ssa-ccp.cc (get_default_value): Ditto.
* tree-ssa-coalesce.cc (populate_coalesce_list_for_outofssa): Ditto.
* tree-ssa-dom.cc (reduce_vector_comparison_to_scalar_comparison): 
Ditto.
* tree-ssa-forwprop.cc (can_propagate_from): Ditto.
* tree-ssa-propagate.cc (may_propagate_copy): Ditto.
* tree-ssa-sccvn.cc (fully_constant_vn_reference_p): Ditto.
* tree-ssa-sink.cc (statement_sink_location): Ditto.
* tree-ssa-structalias.cc (type_must_have_pointers): Ditto.
* tree-ssa-ter.cc (find_replaceable_in_bb): Ditto.
* tree-ssa-uninit.cc (warn_uninit): Ditto.
* tree-ssa.cc (maybe_rewrite_mem_ref_base): Ditto.
(non_rewritable_mem_ref_base): Ditto.
* tree-streamer-in.cc (lto_input_ts_type_non_common_tree_pointers): 
Ditto.
* tree-streamer-out.cc (write_ts_type_non_common_tree_pointers): Ditto.
* tree-vect-generic.cc (do_binop): Ditto.
(do_cond): Ditto.
* tree-vect-stmts.cc (vect_init_vector): Ditto.
* tree-vector-builder.h (tree_vector_builder::note_representative): 
Ditto.
* tree.cc 

[PATCH 00/14] use _P() defines from tree.h

2023-05-13 Thread Bernhard Reutner-Fischer via Gcc-patches
From: Bernhard Reutner-Fischer 

Dear maintainers

I propose the following mechanical change to use the defines in tree.h.
(Common convention is to use the defines as per tree.h, which is what we
keep telling people.)

Exceptions applied to the generator here:
 NULL_TREE # we want to retain "NULL"
 CAN_HAVE_RANGE_P # keep CAN_HAVE_LOCATION_P; Looks confused otherwise.
 No fallback declarations considered. I.e. picks TREE_CODE_CLASS true
 branch (to pick the checking variants of tree access) and skips the
 whole true arm when seeing an extension (like DECL_RTL_KNOWN_SET).
 Case enumerations ignored (CASE_FLT_FN CASE_FLT_FN_FLOATN_NX
 CASE_BUILT_IN_TM_STORE).
 Only _P() named macros without loops are considered for starters.

Bootstrapped on x86_64-unknown-linux with
 --enable-languages=c,fortran,c++,ada,d,go,lto,jit,objc,obj-c++,rust
 (hence not m2) --enable-checking=yes --enable-multilib --disable-libstdcxx-pch
 and regtested without regressions against r14-619-g2499540e9abb55 on
 --target_board=unix'{-m32,-m64}'

Ok for trunk?
PS: I refrain from Ccing about all frontend maintainers in the hopes to
apply this squashed.

Bernhard Reutner-Fischer (14):
  ada: use _P() defines from tree.h
  analyzer: use _P() defines from tree.h
  gcc/config/*: use _P() defines from tree.h
  c++: use _P() defines from tree.h
  m2: use _P() defines from tree.h
  lto: use _P() defines from tree.h
  d: use _P() defines from tree.h
  fortran: use _P() defines from tree.h
  rust: use _P() defines from tree.h
  c: use _P() defines from tree.h
  objc: use _P() defines from tree.h
  go: use _P() defines from tree.h
  omp: use _P() defines from tree.h
  gcc: use _P() defines from tree.h

 gcc/ada/gcc-interface/decl.cc | 17 +++---
 gcc/ada/gcc-interface/trans.cc| 20 +++
 gcc/ada/gcc-interface/utils.cc| 10 ++--
 gcc/ada/gcc-interface/utils2.cc   | 16 +++---
 gcc/alias.cc  |  2 +-
 gcc/analyzer/region-model-manager.cc  |  8 +--
 gcc/analyzer/region-model.cc  |  2 +-
 gcc/analyzer/region.cc|  2 +-
 gcc/attribs.cc| 11 ++--
 gcc/builtins.cc   |  8 +--
 gcc/c-family/c-ada-spec.cc|  6 +--
 gcc/c-family/c-common.cc  | 32 ++--
 gcc/c-family/c-common.h   |  2 +-
 gcc/c-family/c-omp.cc |  5 +-
 gcc/c-family/c-ubsan.cc   |  2 +-
 gcc/c-family/c-warn.cc|  6 +--
 gcc/c/c-convert.cc|  4 +-
 gcc/c/c-decl.cc   |  6 +--
 gcc/c/c-parser.cc |  4 +-
 gcc/c/c-typeck.cc | 52 +--
 gcc/c/gimple-parser.cc|  2 +-
 gcc/cfgexpand.cc  |  2 +-
 gcc/cgraph.h  |  4 +-
 gcc/config/aarch64/aarch64.cc |  4 +-
 gcc/config/alpha/alpha.cc |  6 +--
 gcc/config/arc/arc.cc |  8 +--
 gcc/config/arm/arm.cc | 16 +++---
 gcc/config/arm/unknown-elf.h  |  2 +-
 gcc/config/avr/avr.cc | 11 ++--
 gcc/config/bfin/bfin.cc   |  2 +-
 gcc/config/bpf/bpf.cc |  2 +-
 gcc/config/c6x/c6x.cc |  4 +-
 gcc/config/csky/csky.cc   |  8 ++-
 gcc/config/darwin-c.cc|  2 +-
 gcc/config/darwin.cc  |  2 +-
 gcc/config/epiphany/epiphany.cc   |  3 +-
 gcc/config/epiphany/epiphany.h|  6 +--
 gcc/config/frv/frv.cc |  4 +-
 gcc/config/gcn/gcn-tree.cc|  2 +-
 gcc/config/gcn/gcn.cc |  4 +-
 gcc/config/h8300/h8300.cc |  2 +-
 gcc/config/i386/i386-expand.cc|  2 +-
 gcc/config/i386/i386.cc   | 20 +++
 gcc/config/i386/winnt-cxx.cc  | 12 ++---
 gcc/config/i386/winnt.cc  |  6 +--
 gcc/config/ia64/ia64.cc   |  6 +--
 gcc/config/iq2000/iq2000.cc   |  8 ++-
 gcc/config/lm32/lm32.cc   |  2 +-
 gcc/config/loongarch/loongarch.cc |  2 +-
 gcc/config/m32c/m32c.cc   |  2 +-
 gcc/config/mcore/mcore.cc |  6 +--
 gcc/config/microblaze/microblaze.cc   |  2 +-
 gcc/config/mips/mips.cc   |  2 +-
 gcc/config/mmix/mmix.cc   |  4 +-
 gcc/config/nvptx/nvptx.cc |  8 +--
 gcc/config/pa/pa.cc   | 10 ++--
 gcc/config/pa/pa.h|  4 +-
 gcc/config/pa/som.h   |  2 +-
 gcc/config/pdp11/pdp11.cc 

[PATCH 09/14] rust: use _P() defines from tree.h

2023-05-13 Thread Bernhard Reutner-Fischer via Gcc-patches
From: Bernhard Reutner-Fischer 

gcc/rust/ChangeLog:

* backend/rust-compile-expr.cc (CompileExpr::type_cast_expression): Use
_P() defines from tree.h
* backend/rust-tree.cc (build_cplus_array_type): Ditto.
* backend/rust-tree.h (ARITHMETIC_TYPE_P): Ditto.
(gnu_vector_type_p): Ditto.
* checks/lints/rust-lint-unused-var.cc (check_decl): Ditto.
* rust-gcc.cc (Gcc_backend::fill_in_array): Ditto.
(Gcc_backend::named_type): Ditto.
(Gcc_backend::convert_expression): Ditto.
(Gcc_backend::init_statement): Ditto.
---
 gcc/rust/backend/rust-compile-expr.cc | 2 +-
 gcc/rust/backend/rust-tree.cc | 2 +-
 gcc/rust/backend/rust-tree.h  | 4 ++--
 gcc/rust/checks/lints/rust-lint-unused-var.cc | 2 +-
 gcc/rust/rust-gcc.cc  | 8 
 5 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/gcc/rust/backend/rust-compile-expr.cc 
b/gcc/rust/backend/rust-compile-expr.cc
index d7945dbf26b..3dc34828e32 100644
--- a/gcc/rust/backend/rust-compile-expr.cc
+++ b/gcc/rust/backend/rust-compile-expr.cc
@@ -2267,7 +2267,7 @@ CompileExpr::type_cast_expression (tree type_to_cast_to, 
tree expr_tree,
   // FIXME check for TREE_OVERFLOW?
   return cast;
 }
-  else if (TREE_CODE (type_to_cast_to) == REAL_TYPE)
+  else if (SCALAR_FLOAT_TYPE_P (type_to_cast_to))
 {
   tree cast = convert_to_real (type_to_cast_to, expr_tree);
   // FIXME
diff --git a/gcc/rust/backend/rust-tree.cc b/gcc/rust/backend/rust-tree.cc
index 8243d4cf5c6..7e11e6584ae 100644
--- a/gcc/rust/backend/rust-tree.cc
+++ b/gcc/rust/backend/rust-tree.cc
@@ -2404,7 +2404,7 @@ build_cplus_array_type (tree elt_type, tree index_type, 
int dependent)
 }
 
   /* Avoid spurious warnings with VLAs (c++/54583).  */
-  if (TYPE_SIZE (t) && EXPR_P (TYPE_SIZE (t)))
+  if (CAN_HAVE_LOCATION_P (TYPE_SIZE (t)))
 suppress_warning (TYPE_SIZE (t), OPT_Wunused);
 
   /* Push these needs up to the ARRAY_TYPE so that initialization takes
diff --git a/gcc/rust/backend/rust-tree.h b/gcc/rust/backend/rust-tree.h
index 284fd873c1c..6d243b7f86e 100644
--- a/gcc/rust/backend/rust-tree.h
+++ b/gcc/rust/backend/rust-tree.h
@@ -54,7 +54,7 @@
 
Keep these checks in ascending code order.  */
 #define ARITHMETIC_TYPE_P(TYPE)
\
-  (RS_INTEGRAL_TYPE_P (TYPE) || TREE_CODE (TYPE) == REAL_TYPE  
\
+  (RS_INTEGRAL_TYPE_P (TYPE) || SCALAR_FLOAT_TYPE_P (TYPE)   \
|| TREE_CODE (TYPE) == COMPLEX_TYPE)
 
 /* True iff TYPE is cv decltype(nullptr).  */
@@ -3250,7 +3250,7 @@ identifier_p (tree t)
 inline bool
 gnu_vector_type_p (const_tree type)
 {
-  return TREE_CODE (type) == VECTOR_TYPE && !TYPE_INDIVISIBLE_P (type);
+  return VECTOR_TYPE_P (type) && !TYPE_INDIVISIBLE_P (type);
 }
 
 extern vec *
diff --git a/gcc/rust/checks/lints/rust-lint-unused-var.cc 
b/gcc/rust/checks/lints/rust-lint-unused-var.cc
index ba5ffb9372b..2cf5cd60f15 100644
--- a/gcc/rust/checks/lints/rust-lint-unused-var.cc
+++ b/gcc/rust/checks/lints/rust-lint-unused-var.cc
@@ -25,7 +25,7 @@ namespace Analysis {
 static void
 check_decl (tree *t)
 {
-  rust_assert (TREE_CODE (*t) == VAR_DECL || TREE_CODE (*t) == PARM_DECL
+  rust_assert (VAR_P (*t) || TREE_CODE (*t) == PARM_DECL
   || TREE_CODE (*t) == CONST_DECL);
 
   tree var_name = DECL_NAME (*t);
diff --git a/gcc/rust/rust-gcc.cc b/gcc/rust/rust-gcc.cc
index cf20b5b98e0..b1995bdb56a 100644
--- a/gcc/rust/rust-gcc.cc
+++ b/gcc/rust/rust-gcc.cc
@@ -886,7 +886,7 @@ Gcc_backend::fill_in_array (tree fill, tree element_type, 
tree length_tree)
   if (element_type == error_mark_node || length_tree == error_mark_node)
 return error_mark_node;
 
-  gcc_assert (TYPE_SIZE (element_type) != NULL_TREE);
+  gcc_assert (COMPLETE_TYPE_P (element_type));
 
   length_tree = fold_convert (sizetype, length_tree);
 
@@ -923,7 +923,7 @@ Gcc_backend::named_type (const std::string , tree 
type, Location location)
   // give it whatever Rust name we have at this point.
   if (TYPE_NAME (type) == NULL_TREE
   && location.gcc_location () == BUILTINS_LOCATION
-  && (TREE_CODE (type) == INTEGER_TYPE || TREE_CODE (type) == REAL_TYPE
+  && (TREE_CODE (type) == INTEGER_TYPE || SCALAR_FLOAT_TYPE_P (type)
  || TREE_CODE (type) == COMPLEX_TYPE
  || TREE_CODE (type) == BOOLEAN_TYPE))
 {
@@ -1173,7 +1173,7 @@ Gcc_backend::convert_expression (tree type_tree, tree 
expr_tree,
 }
   else if (TREE_CODE (type_tree) == INTEGER_TYPE)
 ret = convert_to_integer (type_tree, expr_tree);
-  else if (TREE_CODE (type_tree) == REAL_TYPE)
+  else if (SCALAR_FLOAT_TYPE_P (type_tree))
 ret = convert_to_real (type_tree, expr_tree);
   else if (TREE_CODE (type_tree) == COMPLEX_TYPE)
 ret = convert_to_complex (type_tree, expr_tree);
@@ -1935,7 +1935,7 @@ Gcc_backend::init_statement (tree, Bvariable *var, tree 
init_tree)
   tree 

[PATCH 01/14] ada: use _P() defines from tree.h

2023-05-13 Thread Bernhard Reutner-Fischer via Gcc-patches
From: Bernhard Reutner-Fischer 

gcc/ada/ChangeLog:

* gcc-interface/decl.cc (gnat_to_gnu_entity): Use _P defines
from tree.h.
(constructor_address_p): Ditto.
(elaborate_expression_1): Ditto.
* gcc-interface/trans.cc (Identifier_to_gnu): Ditto.
(is_nrv_p): Ditto.
(Subprogram_Body_to_gnu): Ditto.
(gnat_to_gnu): Ditto.
(gnat_to_gnu_external): Ditto.
(add_decl_expr): Ditto.
(gnat_gimplify_expr): Ditto.
* gcc-interface/utils.cc (finish_record_type): Ditto.
(create_var_decl): Ditto.
* gcc-interface/utils2.cc (get_base_type): Ditto.
(build_binary_op): Ditto.
(build_unary_op): Ditto.
(gnat_protect_expr): Ditto.
(gnat_invariant_expr): Ditto.
---
 gcc/ada/gcc-interface/decl.cc   | 17 -
 gcc/ada/gcc-interface/trans.cc  | 20 ++--
 gcc/ada/gcc-interface/utils.cc  | 10 +-
 gcc/ada/gcc-interface/utils2.cc | 16 
 4 files changed, 31 insertions(+), 32 deletions(-)

diff --git a/gcc/ada/gcc-interface/decl.cc b/gcc/ada/gcc-interface/decl.cc
index 20f43de9ea9..ec61593a65b 100644
--- a/gcc/ada/gcc-interface/decl.cc
+++ b/gcc/ada/gcc-interface/decl.cc
@@ -785,7 +785,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, 
bool definition)
if ((TREE_CODE (gnu_type) == UNCONSTRAINED_ARRAY_TYPE
 && No (gnat_renamed_obj))
|| TYPE_IS_DUMMY_P (gnu_type)
-   || TREE_CODE (gnu_type) == VOID_TYPE)
+   || VOID_TYPE_P (gnu_type))
  {
gcc_assert (type_annotate_only);
if (this_global)
@@ -840,7 +840,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, 
bool definition)
if (TREE_CODE (gnu_expr) == COMPONENT_REF
&& TYPE_IS_PADDING_P
   (TREE_TYPE (TREE_OPERAND (gnu_expr, 0)))
-   && TREE_CODE (TREE_OPERAND (gnu_expr, 0)) == VAR_DECL
+   && VAR_P (TREE_OPERAND (gnu_expr, 0))
&& (TREE_READONLY (TREE_OPERAND (gnu_expr, 0))
|| DECL_READONLY_ONCE_ELAB
   (TREE_OPERAND (gnu_expr, 0
@@ -1077,7 +1077,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, 
bool definition)
/* We need to detect the case where a temporary is created to
   hold the return value, since we cannot safely rename it at
   top level as it lives only in the elaboration routine.  */
-   || (TREE_CODE (inner) == VAR_DECL
+   || (VAR_P (inner)
&& DECL_RETURN_VALUE_P (inner))
/* We also need to detect the case where the front-end creates
   a dangling 'reference to a function call at top level and
@@ -1093,10 +1093,10 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree 
gnu_expr, bool definition)
 
   We cannot safely rename the rewritten expression since the
   underlying object lives only in the elaboration routine.  */
-   || (TREE_CODE (inner) == INDIRECT_REF
+   || (INDIRECT_REF_P (inner)
&& (inner
= remove_conversions (TREE_OPERAND (inner, 0), true))
-   && TREE_CODE (inner) == VAR_DECL
+   && VAR_P (inner)
&& DECL_RETURN_VALUE_P (inner)))
  ;
 
@@ -1611,7 +1611,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, 
bool definition)
   and optimization isn't enabled, then force it in memory so that
   a register won't be allocated to it with possible subparts left
   uninitialized and reaching the register allocator.  */
-   else if (TREE_CODE (gnu_decl) == VAR_DECL
+   else if (VAR_P (gnu_decl)
 && !DECL_EXTERNAL (gnu_decl)
 && !TREE_STATIC (gnu_decl)
 && DECL_MODE (gnu_decl) != BLKmode
@@ -6717,8 +6717,7 @@ range_cannot_be_superflat (Node_Id gnat_range)
 static bool
 constructor_address_p (tree gnu_expr)
 {
-  while (TREE_CODE (gnu_expr) == NOP_EXPR
-|| TREE_CODE (gnu_expr) == CONVERT_EXPR
+  while (CONVERT_EXPR_P (gnu_expr)
 || TREE_CODE (gnu_expr) == NON_LVALUE_EXPR)
 gnu_expr = TREE_OPERAND (gnu_expr, 0);
 
@@ -7061,7 +7060,7 @@ elaborate_expression_1 (tree gnu_expr, Entity_Id 
gnat_entity, const char *s,
 
   expr_variable_p
= !(inner
-   && TREE_CODE (inner) == VAR_DECL
+   && VAR_P (inner)
&& (TREE_READONLY (inner) || DECL_READONLY_ONCE_ELAB (inner)));
 }
 
diff --git a/gcc/ada/gcc-interface/trans.cc b/gcc/ada/gcc-interface/trans.cc
index 5fc1a26fede..c26f1b6e1ac 100644
--- a/gcc/ada/gcc-interface/trans.cc
+++ b/gcc/ada/gcc-interface/trans.cc
@@ -1241,7 +1241,7 @@ Identifier_to_gnu (Node_Id gnat_node, tree 
*gnu_result_type_p)
   /* Do the 

[PATCH 04/14] c++: use _P() defines from tree.h

2023-05-13 Thread Bernhard Reutner-Fischer via Gcc-patches
From: Bernhard Reutner-Fischer 

gcc/cp/ChangeLog:

* call.cc (promoted_arithmetic_type_p): Use _P defines from tree.h.
(build_conditional_expr): Ditto.
(convert_like_internal): Ditto.
(convert_arg_to_ellipsis): Ditto.
(build_over_call): Ditto.
(compare_ics): Ditto.
* class.cc (is_empty_base_ref): Ditto.
* coroutines.cc (rewrite_param_uses): Ditto.
* cp-tree.h (DECL_DISCRIMINATOR_P): Ditto.
(ARITHMETIC_TYPE_P): Ditto.
* cvt.cc (ocp_convert): Ditto.
* cxx-pretty-print.cc (pp_cxx_template_argument_list): Ditto.
* decl.cc (layout_var_decl): Ditto.
(get_tuple_size): Ditto.
* error.cc (dump_simple_decl): Ditto.
* lambda.cc (start_lambda_scope): Ditto.
* mangle.cc (write_template_arg): Ditto.
* method.cc (spaceship_comp_cat): Ditto.
* module.cc (node_template_info): Ditto.
(trees_out::start): Ditto.
(trees_out::decl_node): Ditto.
(trees_in::read_var_def): Ditto.
(set_instantiating_module): Ditto.
* name-lookup.cc (maybe_record_mergeable_decl): Ditto.
(consider_decl): Ditto.
(maybe_add_fuzzy_decl): Ditto.
* pt.cc (convert_nontype_argument): Ditto.
* semantics.cc (handle_omp_array_sections_1): Ditto.
(finish_omp_clauses): Ditto.
(finish_omp_target_clauses_r): Ditto.
(is_this_parameter): Ditto.
* tree.cc (build_cplus_array_type): Ditto.
(is_this_expression): Ditto.
* typeck.cc (do_warn_enum_conversions): Ditto.
* typeck2.cc (store_init_value): Ditto.
(check_narrowing): Ditto.
---
 gcc/cp/call.cc | 42 +++---
 gcc/cp/class.cc|  2 +-
 gcc/cp/coroutines.cc   |  2 +-
 gcc/cp/cp-tree.h   |  4 ++--
 gcc/cp/cvt.cc  |  2 +-
 gcc/cp/cxx-pretty-print.cc |  2 +-
 gcc/cp/decl.cc |  4 ++--
 gcc/cp/error.cc|  2 +-
 gcc/cp/lambda.cc   |  2 +-
 gcc/cp/mangle.cc   |  2 +-
 gcc/cp/method.cc   |  2 +-
 gcc/cp/module.cc   | 12 +--
 gcc/cp/name-lookup.cc  |  6 +++---
 gcc/cp/pt.cc   |  2 +-
 gcc/cp/semantics.cc| 24 +++---
 gcc/cp/tree.cc |  4 ++--
 gcc/cp/typeck.cc   |  4 ++--
 gcc/cp/typeck2.cc  | 10 -
 18 files changed, 64 insertions(+), 64 deletions(-)

diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc
index 2a06520c0c1..6e13d17f6b8 100644
--- a/gcc/cp/call.cc
+++ b/gcc/cp/call.cc
@@ -2746,7 +2746,7 @@ promoted_arithmetic_type_p (tree type)
  integral types plus floating types.  */
   return ((CP_INTEGRAL_TYPE_P (type)
   && same_type_p (type_promotes_to (type), type))
- || TREE_CODE (type) == REAL_TYPE);
+ || SCALAR_FLOAT_TYPE_P (type));
 }
 
 /* Create any builtin operator overload candidates for the operator in
@@ -5759,10 +5759,10 @@ build_conditional_expr (const op_location_t ,
   if ((TREE_CODE (arg2) == EXCESS_PRECISION_EXPR
|| TREE_CODE (arg3) == EXCESS_PRECISION_EXPR)
   && (TREE_CODE (arg2_type) == INTEGER_TYPE
- || TREE_CODE (arg2_type) == REAL_TYPE
+ || SCALAR_FLOAT_TYPE_P (arg2_type)
  || TREE_CODE (arg2_type) == COMPLEX_TYPE)
   && (TREE_CODE (arg3_type) == INTEGER_TYPE
- || TREE_CODE (arg3_type) == REAL_TYPE
+ || SCALAR_FLOAT_TYPE_P (arg3_type)
  || TREE_CODE (arg3_type) == COMPLEX_TYPE))
 {
   semantic_result_type
@@ -5775,8 +5775,8 @@ build_conditional_expr (const op_location_t ,
t1 = TREE_TYPE (t1);
  if (TREE_CODE (t2) == COMPLEX_TYPE)
t2 = TREE_TYPE (t2);
- gcc_checking_assert (TREE_CODE (t1) == REAL_TYPE
-  && TREE_CODE (t2) == REAL_TYPE
+ gcc_checking_assert (SCALAR_FLOAT_TYPE_P (t1)
+  && SCALAR_FLOAT_TYPE_P (t2)
   && (extended_float_type_p (t1)
   || extended_float_type_p (t2))
   && cp_compare_floating_point_conversion_ranks
@@ -6127,8 +6127,8 @@ build_conditional_expr (const op_location_t ,
t1 = TREE_TYPE (t1);
  if (TREE_CODE (t2) == COMPLEX_TYPE)
t2 = TREE_TYPE (t2);
- gcc_checking_assert (TREE_CODE (t1) == REAL_TYPE
-  && TREE_CODE (t2) == REAL_TYPE
+ gcc_checking_assert (SCALAR_FLOAT_TYPE_P (t1)
+  && SCALAR_FLOAT_TYPE_P (t2)
   && (extended_float_type_p (t1)
   || extended_float_type_p (t2))
   && cp_compare_floating_point_conversion_ranks
@@ -6147,8 +6147,8 @@ build_conditional_expr (const op_location_t ,
t1 = TREE_TYPE (t1);
  if (TREE_CODE (t2) == COMPLEX_TYPE)
t2 = TREE_TYPE (t2);
- 

[PATCH 03/14] gcc/config/*: use _P() defines from tree.h

2023-05-13 Thread Bernhard Reutner-Fischer via Gcc-patches
From: Bernhard Reutner-Fischer 

gcc/ChangeLog:

* config/aarch64/aarch64.cc (aarch64_short_vector_p): Use _P
defines from tree.h.
(aarch64_mangle_type): Ditto.
* config/alpha/alpha.cc (alpha_in_small_data_p): Ditto.
(alpha_gimplify_va_arg_1): Ditto.
* config/arc/arc.cc (arc_encode_section_info): Ditto.
(arc_is_aux_reg_p): Ditto.
(arc_is_uncached_mem_p): Ditto.
(arc_handle_aux_attribute): Ditto.
* config/arm/arm.cc (arm_handle_isr_attribute): Ditto.
(arm_handle_cmse_nonsecure_call): Ditto.
(arm_set_default_type_attributes): Ditto.
(arm_is_segment_info_known): Ditto.
(arm_mangle_type): Ditto.
* config/arm/unknown-elf.h (IN_NAMED_SECTION_P): Ditto.
* config/avr/avr.cc (avr_lookup_function_attribute1): Ditto.
(avr_decl_absdata_p): Ditto.
(avr_insert_attributes): Ditto.
(avr_section_type_flags): Ditto.
(avr_encode_section_info): Ditto.
* config/bfin/bfin.cc (bfin_handle_l2_attribute): Ditto.
* config/bpf/bpf.cc (bpf_core_compute): Ditto.
* config/c6x/c6x.cc (c6x_in_small_data_p): Ditto.
* config/csky/csky.cc (csky_handle_isr_attribute): Ditto.
(csky_mangle_type): Ditto.
* config/darwin-c.cc (darwin_pragma_unused): Ditto.
* config/darwin.cc (is_objc_metadata): Ditto.
* config/epiphany/epiphany.cc (epiphany_function_ok_for_sibcall): Ditto.
* config/epiphany/epiphany.h (ROUND_TYPE_ALIGN): Ditto.
* config/frv/frv.cc (frv_emit_movsi): Ditto.
* config/gcn/gcn-tree.cc (gcn_lockless_update): Ditto.
* config/gcn/gcn.cc (gcn_asm_output_symbol_ref): Ditto.
* config/h8300/h8300.cc (h8300_encode_section_info): Ditto.
* config/i386/i386-expand.cc: Ditto.
* config/i386/i386.cc (type_natural_mode): Ditto.
(ix86_function_arg): Ditto.
(ix86_data_alignment): Ditto.
(ix86_local_alignment): Ditto.
(ix86_simd_clone_compute_vecsize_and_simdlen): Ditto.
* config/i386/winnt-cxx.cc (i386_pe_type_dllimport_p): Ditto.
(i386_pe_type_dllexport_p): Ditto.
(i386_pe_adjust_class_at_definition): Ditto.
* config/i386/winnt.cc (i386_pe_determine_dllimport_p): Ditto.
(i386_pe_binds_local_p): Ditto.
(i386_pe_section_type_flags): Ditto.
* config/ia64/ia64.cc (ia64_encode_section_info): Ditto.
(ia64_gimplify_va_arg): Ditto.
(ia64_in_small_data_p): Ditto.
* config/iq2000/iq2000.cc (iq2000_function_arg): Ditto.
* config/lm32/lm32.cc (lm32_in_small_data_p): Ditto.
* config/loongarch/loongarch.cc (loongarch_handle_model_attribute): 
Ditto.
* config/m32c/m32c.cc (m32c_insert_attributes): Ditto.
* config/mcore/mcore.cc (mcore_mark_dllimport): Ditto.
(mcore_encode_section_info): Ditto.
* config/microblaze/microblaze.cc (microblaze_elf_in_small_data_p): 
Ditto.
* config/mips/mips.cc (mips_output_aligned_decl_common): Ditto.
* config/mmix/mmix.cc (mmix_encode_section_info): Ditto.
* config/nvptx/nvptx.cc (nvptx_encode_section_info): Ditto.
(pass_in_memory): Ditto.
(nvptx_generate_vector_shuffle): Ditto.
(nvptx_lockless_update): Ditto.
* config/pa/pa.cc (pa_function_arg_padding): Ditto.
(pa_function_value): Ditto.
(pa_function_arg): Ditto.
* config/pa/pa.h (IN_NAMED_SECTION_P): Ditto.
(TEXT_SPACE_P): Ditto.
* config/pa/som.h (MAKE_DECL_ONE_ONLY): Ditto.
* config/pdp11/pdp11.cc (pdp11_return_in_memory): Ditto.
* config/riscv/riscv.cc (riscv_in_small_data_p): Ditto.
(riscv_mangle_type): Ditto.
* config/rl78/rl78.cc (rl78_insert_attributes): Ditto.
(rl78_addsi3_internal): Ditto.
* config/rs6000/aix.h (ROUND_TYPE_ALIGN): Ditto.
* config/rs6000/darwin.h (ROUND_TYPE_ALIGN): Ditto.
* config/rs6000/freebsd64.h (ROUND_TYPE_ALIGN): Ditto.
* config/rs6000/linux64.h (ROUND_TYPE_ALIGN): Ditto.
* config/rs6000/rs6000-call.cc (rs6000_function_arg_boundary): Ditto.
(rs6000_function_arg_advance_1): Ditto.
(rs6000_function_arg): Ditto.
(rs6000_pass_by_reference): Ditto.
* config/rs6000/rs6000-logue.cc (rs6000_function_ok_for_sibcall): Ditto.
* config/rs6000/rs6000.cc (rs6000_data_alignment): Ditto.
(rs6000_set_default_type_attributes): Ditto.
(rs6000_elf_in_small_data_p): Ditto.
(IN_NAMED_SECTION): Ditto.
(rs6000_xcoff_encode_section_info): Ditto.
(rs6000_function_value): Ditto.
(invalid_arg_for_unprototyped_fn): Ditto.
* config/s390/s390-c.cc (s390_fn_types_compatible): Ditto.
(s390_vec_n_elem): Ditto.
* config/s390/s390.cc (s390_check_type_for_vector_abi): Ditto.
(s390_function_arg_integer): Ditto.
(s390_return_in_memory): Ditto.

[PATCH 08/14] fortran: use _P() defines from tree.h

2023-05-13 Thread Bernhard Reutner-Fischer via Gcc-patches
From: Bernhard Reutner-Fischer 

gcc/fortran/ChangeLog:

* trans-array.cc (is_pointer_array): Use _P() defines from tree.h.
(gfc_conv_scalarized_array_ref): Ditto.
(gfc_conv_array_ref): Ditto.
* trans-decl.cc (gfc_finish_decl): Ditto.
(gfc_get_symbol_decl): Ditto.
* trans-expr.cc (gfc_trans_pointer_assignment): Ditto.
(gfc_trans_arrayfunc_assign): Ditto.
(gfc_trans_assignment_1): Ditto.
* trans-intrinsic.cc (gfc_conv_intrinsic_minmax): Ditto.
(conv_intrinsic_ieee_value): Ditto.
* trans-io.cc (gfc_convert_array_to_string): Ditto.
* trans-openmp.cc (gfc_omp_is_optional_argument): Ditto.
(gfc_trans_omp_clauses): Ditto.
* trans-stmt.cc (gfc_conv_label_variable): Ditto.
* trans.cc (gfc_build_addr_expr): Ditto.
(get_array_span): Ditto.
---
 gcc/fortran/trans-array.cc | 10 +-
 gcc/fortran/trans-decl.cc  |  4 ++--
 gcc/fortran/trans-expr.cc  |  6 +++---
 gcc/fortran/trans-intrinsic.cc |  4 ++--
 gcc/fortran/trans-io.cc|  2 +-
 gcc/fortran/trans-openmp.cc|  7 +++
 gcc/fortran/trans-stmt.cc  |  2 +-
 gcc/fortran/trans.cc   |  4 ++--
 8 files changed, 19 insertions(+), 20 deletions(-)

diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index 9f8aa09673a..15719845ca8 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -880,7 +880,7 @@ is_pointer_array (tree expr)
   || GFC_CLASS_TYPE_P (TREE_TYPE (expr)))
 return false;
 
-  if (TREE_CODE (expr) == VAR_DECL
+  if (VAR_P (expr)
   && GFC_DECL_PTR_ARRAY_P (expr))
 return true;
 
@@ -888,7 +888,7 @@ is_pointer_array (tree expr)
   && GFC_DECL_PTR_ARRAY_P (expr))
 return true;
 
-  if (TREE_CODE (expr) == INDIRECT_REF
+  if (INDIRECT_REF_P (expr)
   && GFC_DECL_PTR_ARRAY_P (TREE_OPERAND (expr, 0)))
 return true;
 
@@ -3803,7 +3803,7 @@ gfc_conv_scalarized_array_ref (gfc_se * se, gfc_array_ref 
* ar,
 {
   if (TREE_CODE (info->descriptor) == COMPONENT_REF)
decl = info->descriptor;
-  else if (TREE_CODE (info->descriptor) == INDIRECT_REF)
+  else if (INDIRECT_REF_P (info->descriptor))
decl = TREE_OPERAND (info->descriptor, 0);
 
   if (decl == NULL_TREE)
@@ -4057,7 +4057,7 @@ gfc_conv_array_ref (gfc_se * se, gfc_array_ref * ar, 
gfc_expr *expr,
 {
   if (TREE_CODE (se->expr) == COMPONENT_REF)
decl = se->expr;
-  else if (TREE_CODE (se->expr) == INDIRECT_REF)
+  else if (INDIRECT_REF_P (se->expr))
decl = TREE_OPERAND (se->expr, 0);
   else
decl = se->expr;
@@ -4069,7 +4069,7 @@ gfc_conv_array_ref (gfc_se * se, gfc_array_ref * ar, 
gfc_expr *expr,
   if (GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (se->expr)))
{
  decl = se->expr;
- if (TREE_CODE (decl) == INDIRECT_REF)
+ if (INDIRECT_REF_P (decl))
decl = TREE_OPERAND (decl, 0);
}
   else
diff --git a/gcc/fortran/trans-decl.cc b/gcc/fortran/trans-decl.cc
index cd32542eb86..7f21dc2b09f 100644
--- a/gcc/fortran/trans-decl.cc
+++ b/gcc/fortran/trans-decl.cc
@@ -558,7 +558,7 @@ gfc_finish_decl (tree decl)
 return;
 
   if (DECL_SIZE (decl) == NULL_TREE
-  && TYPE_SIZE (TREE_TYPE (decl)) != NULL_TREE)
+  && COMPLETE_TYPE_P (TREE_TYPE (decl)))
 layout_decl (decl, 0);
 
   /* A few consistency checks.  */
@@ -1889,7 +1889,7 @@ gfc_get_symbol_decl (gfc_symbol * sym)
   length = fold_convert (gfc_charlen_type_node, length);
   gfc_finish_var_decl (length, sym);
   if (!sym->attr.associate_var
- && TREE_CODE (length) == VAR_DECL
+ && VAR_P (length)
  && sym->value && sym->value->expr_type != EXPR_NULL
  && sym->value->ts.u.cl->length)
{
diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc
index d902e8f3281..292aba76aaa 100644
--- a/gcc/fortran/trans-expr.cc
+++ b/gcc/fortran/trans-expr.cc
@@ -10246,7 +10246,7 @@ gfc_trans_pointer_assignment (gfc_expr * expr1, 
gfc_expr * expr2)
  gfc_conv_descriptor_data_set (, desc, data);
 
  /* Copy the span.  */
- if (TREE_CODE (rse.expr) == VAR_DECL
+ if (VAR_P (rse.expr)
  && GFC_DECL_PTR_ARRAY_P (rse.expr))
span = gfc_conv_descriptor_span_get (rse.expr);
  else
@@ -10933,7 +10933,7 @@ gfc_trans_arrayfunc_assign (gfc_expr * expr1, gfc_expr 
* expr2)
 {
   tmp = sym->backend_decl;
   lhs = sym->backend_decl;
-  if (TREE_CODE (tmp) == INDIRECT_REF)
+  if (INDIRECT_REF_P (tmp))
tmp = TREE_OPERAND (tmp, 0);
   sym->backend_decl = gfc_create_var (TREE_TYPE (tmp), "lhs");
   gfc_add_modify (, sym->backend_decl, tmp);
@@ -11883,7 +11883,7 @@ gfc_trans_assignment_1 (gfc_expr * expr1, gfc_expr * 
expr2, bool init_flag,
   if (expr2->ts.type == BT_CHARACTER && !expr1->ts.deferred
   && !(VAR_P (rse.string_length)
   

[PATCH 05/14] m2: use _P() defines from tree.h

2023-05-13 Thread Bernhard Reutner-Fischer via Gcc-patches
From: Bernhard Reutner-Fischer 

gcc/m2/ChangeLog:

* gm2-gcc/m2builtins.cc (doradix): Use _P defines from tree.h.
(doplaces): Ditto.
(doexponentmin): Ditto.
(doexponentmax): Ditto.
(dolarge): Ditto.
(dosmall): Ditto.
(dogUnderflow): Ditto.
* gm2-gcc/m2convert.cc (unsafe_conversion_p): Ditto.
* gm2-gcc/m2expr.cc (m2expr_build_unary_op_check): Ditto.
(m2expr_build_binary_op_check): Ditto.
* gm2-gcc/m2tree.cc (m2tree_is_var): Ditto.
* gm2-gcc/m2treelib.cc (build_modify_expr): Ditto.
* gm2-gcc/m2type.cc (gm2_finish_decl): Ditto.
* m2pp.cc (hextree): Ditto.
(m2pp_call_expr): Ditto.
---
 gcc/m2/gm2-gcc/m2builtins.cc | 14 +++---
 gcc/m2/gm2-gcc/m2convert.cc  |  8 
 gcc/m2/gm2-gcc/m2expr.cc |  4 ++--
 gcc/m2/gm2-gcc/m2tree.cc |  2 +-
 gcc/m2/gm2-gcc/m2treelib.cc  |  2 +-
 gcc/m2/gm2-gcc/m2type.cc |  4 ++--
 gcc/m2/m2pp.cc   |  4 ++--
 7 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/gcc/m2/gm2-gcc/m2builtins.cc b/gcc/m2/gm2-gcc/m2builtins.cc
index 8d104c41a1e..3d13e2018d7 100644
--- a/gcc/m2/gm2-gcc/m2builtins.cc
+++ b/gcc/m2/gm2-gcc/m2builtins.cc
@@ -552,7 +552,7 @@ m2builtins_GetBuiltinTypeInfo (location_t location, tree 
type,
 static tree
 doradix (location_t location ATTRIBUTE_UNUSED, tree type)
 {
-  if (TREE_CODE (type) == REAL_TYPE)
+  if (SCALAR_FLOAT_TYPE_P (type))
 {
   enum machine_mode mode = TYPE_MODE (type);
   int radix = REAL_MODE_FORMAT (mode)->b;
@@ -568,7 +568,7 @@ doradix (location_t location ATTRIBUTE_UNUSED, tree type)
 static tree
 doplaces (location_t location ATTRIBUTE_UNUSED, tree type)
 {
-  if (TREE_CODE (type) == REAL_TYPE)
+  if (SCALAR_FLOAT_TYPE_P (type))
 {
   /* Taken from c-family/c-cppbuiltin.cc.  */
   /* The number of decimal digits, q, such that any floating-point
@@ -592,7 +592,7 @@ doplaces (location_t location ATTRIBUTE_UNUSED, tree type)
 static tree
 doexponentmin (location_t location ATTRIBUTE_UNUSED, tree type)
 {
-  if (TREE_CODE (type) == REAL_TYPE)
+  if (SCALAR_FLOAT_TYPE_P (type))
 {
   enum machine_mode mode = TYPE_MODE (type);
   int emin = REAL_MODE_FORMAT (mode)->emin;
@@ -607,7 +607,7 @@ doexponentmin (location_t location ATTRIBUTE_UNUSED, tree 
type)
 static tree
 doexponentmax (location_t location ATTRIBUTE_UNUSED, tree type)
 {
-  if (TREE_CODE (type) == REAL_TYPE)
+  if (SCALAR_FLOAT_TYPE_P (type))
 {
   enum machine_mode mode = TYPE_MODE (type);
   int emax = REAL_MODE_FORMAT (mode)->emax;
@@ -640,7 +640,7 @@ computeLarge (tree type)
 static tree
 dolarge (location_t location ATTRIBUTE_UNUSED, tree type)
 {
-  if (TREE_CODE (type) == REAL_TYPE)
+  if (SCALAR_FLOAT_TYPE_P (type))
 return computeLarge (type);
   return NULL_TREE;
 }
@@ -667,7 +667,7 @@ computeSmall (tree type)
 static tree
 dosmall (location_t location ATTRIBUTE_UNUSED, tree type)
 {
-  if (TREE_CODE (type) == REAL_TYPE)
+  if (SCALAR_FLOAT_TYPE_P (type))
 return computeSmall (type);
   return NULL_TREE;
 }
@@ -735,7 +735,7 @@ dorounds (location_t location ATTRIBUTE_UNUSED, tree type 
ATTRIBUTE_UNUSED)
 static tree
 dogUnderflow (location_t location ATTRIBUTE_UNUSED, tree type)
 {
-  if (TREE_CODE (type) == REAL_TYPE)
+  if (SCALAR_FLOAT_TYPE_P (type))
 {
   enum machine_mode mode = TYPE_MODE (type);
   const struct real_format *fmt = REAL_MODE_FORMAT (mode);
diff --git a/gcc/m2/gm2-gcc/m2convert.cc b/gcc/m2/gm2-gcc/m2convert.cc
index f806669dc39..5d35bcee239 100644
--- a/gcc/m2/gm2-gcc/m2convert.cc
+++ b/gcc/m2/gm2-gcc/m2convert.cc
@@ -91,7 +91,7 @@ unsafe_conversion_p (location_t loc, tree type, tree expr, 
bool produce_warns)
 
   /* Warn for real constant that is not an exact integer converted to
  integer type.  */
-  if (TREE_CODE (expr_type) == REAL_TYPE
+  if (SCALAR_FLOAT_TYPE_P (expr_type)
   && TREE_CODE (type) == INTEGER_TYPE)
 {
   if (!real_isinteger (TREE_REAL_CST_PTR (expr),
@@ -121,7 +121,7 @@ unsafe_conversion_p (location_t loc, tree type, tree expr, 
bool produce_warns)
   else
 give_warning = UNSAFE_OTHER;
 }
-  else if (TREE_CODE (type) == REAL_TYPE)
+  else if (SCALAR_FLOAT_TYPE_P (type))
 {
   /* Warn for an integer constant that does not fit into real type.  */
   if (TREE_CODE (expr_type) == INTEGER_TYPE)
@@ -133,7 +133,7 @@ unsafe_conversion_p (location_t loc, tree type, tree expr, 
bool produce_warns)
 
   /* Warn for a real constant that does not fit into a smaller real
   type.  */
-  else if (TREE_CODE (expr_type) == REAL_TYPE
+ else if (SCALAR_FLOAT_TYPE_P (expr_type)
&& TYPE_PRECISION (type) < TYPE_PRECISION (expr_type))
 {
   REAL_VALUE_TYPE a = TREE_REAL_CST (expr);
@@ -145,7 +145,7 @@ unsafe_conversion_p (location_t loc, tree type, tree 

[PATCH 11/14] objc: use _P() defines from tree.h

2023-05-13 Thread Bernhard Reutner-Fischer via Gcc-patches
From: Bernhard Reutner-Fischer 

gcc/objc/ChangeLog:

* objc-act.cc (objc_volatilize_decl): Use _P() defines from tree.h.
(objc_is_global_reference_p): Ditto.
(objc_generate_write_barrier): Ditto.
(objc_gimplify_property_ref): Ditto.
* objc-next-runtime-abi-01.cc 
(next_runtime_abi_01_receiver_is_class_object): Ditto.
* objc-next-runtime-abi-02.cc 
(next_runtime_abi_02_receiver_is_class_object): Ditto.
(next_runtime_abi_02_build_objc_method_call): Ditto.
---
 gcc/objc/objc-act.cc | 10 +-
 gcc/objc/objc-next-runtime-abi-01.cc |  2 +-
 gcc/objc/objc-next-runtime-abi-02.cc |  4 ++--
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/gcc/objc/objc-act.cc b/gcc/objc/objc-act.cc
index 08201749207..e4c49e664e1 100644
--- a/gcc/objc/objc-act.cc
+++ b/gcc/objc/objc-act.cc
@@ -2338,7 +2338,7 @@ objc_volatilize_decl (tree decl)
   /* Do not mess with variables that are 'static' or (already)
  'volatile'.  */
   if (!TREE_THIS_VOLATILE (decl) && !TREE_STATIC (decl)
-  && (TREE_CODE (decl) == VAR_DECL
+  && (VAR_P (decl)
  || TREE_CODE (decl) == PARM_DECL))
 {
   if (local_variables_to_volatilize == NULL)
@@ -3793,7 +3793,7 @@ objc_is_ivar_reference_p (tree expr)
 static int
 objc_is_global_reference_p (tree expr)
 {
-  return (TREE_CODE (expr) == INDIRECT_REF || TREE_CODE (expr) == PLUS_EXPR
+  return (INDIRECT_REF_P (expr) || TREE_CODE (expr) == PLUS_EXPR
  ? objc_is_global_reference_p (TREE_OPERAND (expr, 0))
  : DECL_P (expr)
  ? (DECL_FILE_SCOPE_P (expr) || TREE_STATIC (expr))
@@ -3812,7 +3812,7 @@ objc_generate_write_barrier (tree lhs, enum tree_code 
modifycode, tree rhs)
 
   /* See if we have any lhs casts, and strip them out.  NB: The lvalue casts
  will have been transformed to the form '*(type *)'.  */
-  if (TREE_CODE (lhs) == INDIRECT_REF)
+  if (INDIRECT_REF_P (lhs))
 {
   outer = TREE_OPERAND (lhs, 0);
 
@@ -3864,7 +3864,7 @@ objc_generate_write_barrier (tree lhs, enum tree_code 
modifycode, tree rhs)
 || TREE_CODE (outer) == ARRAY_REF))
 outer = TREE_OPERAND (outer, 0);
 
-  if (TREE_CODE (outer) == INDIRECT_REF)
+  if (INDIRECT_REF_P (outer))
 {
   outer = TREE_OPERAND (outer, 0);
   indirect_p = 1;
@@ -9694,7 +9694,7 @@ objc_gimplify_property_ref (tree *expr_p)
   if (TREE_CODE (getter) == TARGET_EXPR)
 {
   gcc_assert (MAYBE_CLASS_TYPE_P (TREE_TYPE (getter)));
-  gcc_assert (TREE_CODE (TREE_OPERAND (getter, 0)) == VAR_DECL);
+  gcc_assert (VAR_P (TREE_OPERAND (getter, 0)));
   call_exp = TREE_OPERAND (getter, 1);
 }
 #endif
diff --git a/gcc/objc/objc-next-runtime-abi-01.cc 
b/gcc/objc/objc-next-runtime-abi-01.cc
index 8f68f784efe..70ab5262e17 100644
--- a/gcc/objc/objc-next-runtime-abi-01.cc
+++ b/gcc/objc/objc-next-runtime-abi-01.cc
@@ -754,7 +754,7 @@ next_runtime_abi_01_get_arg_type_list_base (vec **argtypes,
 static tree
 next_runtime_abi_01_receiver_is_class_object (tree receiver)
 {
-  if (TREE_CODE (receiver) == VAR_DECL
+  if (VAR_P (receiver)
   && IS_CLASS (TREE_TYPE (receiver)))
 {
   /* The receiver is a variable created by build_class_reference_decl.  */
diff --git a/gcc/objc/objc-next-runtime-abi-02.cc 
b/gcc/objc/objc-next-runtime-abi-02.cc
index bcfc0ce8e19..6548c0078e0 100644
--- a/gcc/objc/objc-next-runtime-abi-02.cc
+++ b/gcc/objc/objc-next-runtime-abi-02.cc
@@ -1571,7 +1571,7 @@ next_runtime_abi_02_get_category_super_ref (location_t 
loc ATTRIBUTE_UNUSED,
 static tree
 next_runtime_abi_02_receiver_is_class_object (tree receiver)
 {
-  if (TREE_CODE (receiver) == VAR_DECL
+  if (VAR_P (receiver)
   && IS_CLASS (TREE_TYPE (receiver))
   && vec_safe_length (classrefs))
 {
@@ -1824,7 +1824,7 @@ next_runtime_abi_02_build_objc_method_call (location_t 
loc,
   checked.  */
   bool check_for_nil = flag_objc_nilcheck;
   if (super
-  || (TREE_CODE (receiver) == VAR_DECL
+  || (VAR_P (receiver)
  && TREE_TYPE (receiver) == objc_class_type))
 check_for_nil = false;
 
-- 
2.30.2



[PATCH 12/14] go: use _P() defines from tree.h

2023-05-13 Thread Bernhard Reutner-Fischer via Gcc-patches
From: Bernhard Reutner-Fischer 

gcc/go/ChangeLog:

* go-gcc.cc (Gcc_backend::fill_in_array): Use _P() defines from tree.h.
(Gcc_backend::named_type): Ditto.
(Gcc_backend::convert_expression): Ditto.
(operator_to_tree_code): Ditto.
(Gcc_backend::init_statement): Ditto.

gcc/ChangeLog:

* godump.cc (go_format_type): Ditto.
(go_output_typedef): Ditto.
---
 gcc/go/go-gcc.cc | 10 +-
 gcc/godump.cc|  4 ++--
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/gcc/go/go-gcc.cc b/gcc/go/go-gcc.cc
index 41ae9f83731..ad001a9044a 100644
--- a/gcc/go/go-gcc.cc
+++ b/gcc/go/go-gcc.cc
@@ -1168,7 +1168,7 @@ Gcc_backend::fill_in_array(Btype* fill, Btype* 
element_type,
   if (element_type_tree == error_mark_node || length_tree == error_mark_node)
 return this->error_type();
 
-  gcc_assert(TYPE_SIZE(element_type_tree) != NULL_TREE);
+  gcc_assert (COMPLETE_TYPE_P (element_type_tree));
 
   length_tree = fold_convert(sizetype, length_tree);
 
@@ -1347,7 +1347,7 @@ Gcc_backend::named_type(const std::string& name, Btype* 
btype,
   if (TYPE_NAME(type) == NULL_TREE
   && location.gcc_location() == BUILTINS_LOCATION
   && (TREE_CODE(type) == INTEGER_TYPE
- || TREE_CODE(type) == REAL_TYPE
+ || SCALAR_FLOAT_TYPE_P (type)
  || TREE_CODE(type) == COMPLEX_TYPE
  || TREE_CODE(type) == BOOLEAN_TYPE))
 {
@@ -1670,7 +1670,7 @@ Gcc_backend::convert_expression(Btype* type, Bexpression* 
expr,
 }
   else if (TREE_CODE(type_tree) == INTEGER_TYPE)
 ret = fold(convert_to_integer(type_tree, expr_tree));
-  else if (TREE_CODE(type_tree) == REAL_TYPE)
+  else if (SCALAR_FLOAT_TYPE_P (type_tree))
 ret = fold(convert_to_real(type_tree, expr_tree));
   else if (TREE_CODE(type_tree) == COMPLEX_TYPE)
 ret = fold(convert_to_complex(type_tree, expr_tree));
@@ -1880,7 +1880,7 @@ operator_to_tree_code(Operator op, tree type)
   code = MULT_EXPR;
   break;
 case OPERATOR_DIV:
-  if (TREE_CODE(type) == REAL_TYPE || TREE_CODE(type) == COMPLEX_TYPE)
+  if (SCALAR_FLOAT_TYPE_P (type) || TREE_CODE (type) == COMPLEX_TYPE)
code = RDIV_EXPR;
   else
code = TRUNC_DIV_EXPR;
@@ -2223,7 +2223,7 @@ Gcc_backend::init_statement(Bfunction*, Bvariable* var, 
Bexpression* init)
   tree init_tree = init->get_tree();
   if (var_tree == error_mark_node || init_tree == error_mark_node)
 return this->error_statement();
-  gcc_assert(TREE_CODE(var_tree) == VAR_DECL);
+  gcc_assert (VAR_P (var_tree));
 
   // To avoid problems with GNU ld, we don't make zero-sized
   // externally visible variables.  That might lead us to doing an
diff --git a/gcc/godump.cc b/gcc/godump.cc
index 0893d5fbc97..1a62753af12 100644
--- a/gcc/godump.cc
+++ b/gcc/godump.cc
@@ -791,7 +791,7 @@ go_format_type (class godump_container *container, tree 
type,
tree real_type;
 
real_type = TREE_TYPE (type);
-   if (TREE_CODE (real_type) == REAL_TYPE)
+   if (SCALAR_FLOAT_TYPE_P (real_type))
  {
switch (TYPE_PRECISION (real_type))
  {
@@ -1100,7 +1100,7 @@ go_output_typedef (class godump_container *container, 
tree decl)
   if (TREE_CODE (TREE_TYPE (decl)) == ENUMERAL_TYPE
   && TYPE_SIZE (TREE_TYPE (decl)) != 0
   && !container->decls_seen.contains (TREE_TYPE (decl))
-  && (TYPE_CANONICAL (TREE_TYPE (decl)) == NULL_TREE
+  && (TYPE_STRUCTURAL_EQUALITY_P (TREE_TYPE (decl))
  || !container->decls_seen.contains
(TYPE_CANONICAL (TREE_TYPE (decl)
 {
-- 
2.30.2



[PATCH 13/14] omp: use _P() defines from tree.h

2023-05-13 Thread Bernhard Reutner-Fischer via Gcc-patches
From: Bernhard Reutner-Fischer 

gcc/ChangeLog:

* omp-low.cc (scan_sharing_clauses): Use _P() defines from tree.h.
(lower_reduction_clauses): Ditto.
(lower_send_clauses): Ditto.
(lower_omp_task_reductions): Ditto.
* omp-oacc-neuter-broadcast.cc (install_var_field): Ditto.
(worker_single_copy): Ditto.
* omp-offload.cc (oacc_rewrite_var_decl): Ditto.
* omp-simd-clone.cc (plausible_type_for_simd_clone): Ditto.
---
 gcc/omp-low.cc   | 36 
 gcc/omp-oacc-neuter-broadcast.cc | 10 -
 gcc/omp-offload.cc   |  2 +-
 gcc/omp-simd-clone.cc|  2 +-
 4 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/gcc/omp-low.cc b/gcc/omp-low.cc
index dddf5b59d8f..9db33d2a48b 100644
--- a/gcc/omp-low.cc
+++ b/gcc/omp-low.cc
@@ -1267,7 +1267,7 @@ scan_sharing_clauses (tree clauses, omp_context *ctx)
  tree t = TREE_OPERAND (decl, 0);
  if (TREE_CODE (t) == POINTER_PLUS_EXPR)
t = TREE_OPERAND (t, 0);
- if (TREE_CODE (t) == INDIRECT_REF
+ if (INDIRECT_REF_P (t)
  || TREE_CODE (t) == ADDR_EXPR)
t = TREE_OPERAND (t, 0);
  if (is_omp_target (ctx->stmt))
@@ -1276,7 +1276,7 @@ scan_sharing_clauses (tree clauses, omp_context *ctx)
{
  gcc_assert (DECL_HAS_VALUE_EXPR_P (t));
  t = DECL_VALUE_EXPR (t);
- gcc_assert (TREE_CODE (t) == INDIRECT_REF);
+ gcc_assert (INDIRECT_REF_P (t));
  t = TREE_OPERAND (t, 0);
  gcc_assert (DECL_P (t));
}
@@ -1383,7 +1383,7 @@ scan_sharing_clauses (tree clauses, omp_context *ctx)
}
  else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_HAS_DEVICE_ADDR)
{
- if (TREE_CODE (decl) == INDIRECT_REF)
+ if (INDIRECT_REF_P (decl))
decl = TREE_OPERAND (decl, 0);
  install_var_field (decl, true, 3, ctx);
}
@@ -1457,7 +1457,7 @@ scan_sharing_clauses (tree clauses, omp_context *ctx)
  && TREE_CODE (DECL_SIZE (decl)) != INTEGER_CST)
{
  tree decl2 = DECL_VALUE_EXPR (decl);
- gcc_assert (TREE_CODE (decl2) == INDIRECT_REF);
+ gcc_assert (INDIRECT_REF_P (decl2));
  decl2 = TREE_OPERAND (decl2, 0);
  gcc_assert (DECL_P (decl2));
  install_var_local (decl2, ctx);
@@ -1467,7 +1467,7 @@ scan_sharing_clauses (tree clauses, omp_context *ctx)
 
case OMP_CLAUSE_HAS_DEVICE_ADDR:
  decl = OMP_CLAUSE_DECL (c);
- while (TREE_CODE (decl) == INDIRECT_REF
+ while (INDIRECT_REF_P (decl)
 || TREE_CODE (decl) == ARRAY_REF)
decl = TREE_OPERAND (decl, 0);
  goto do_private;
@@ -1635,7 +1635,7 @@ scan_sharing_clauses (tree clauses, omp_context *ctx)
  == GOMP_MAP_FIRSTPRIVATE_REFERENCE)))
{
  if (TREE_CODE (decl) == COMPONENT_REF
- || (TREE_CODE (decl) == INDIRECT_REF
+ || (INDIRECT_REF_P (decl)
  && TREE_CODE (TREE_OPERAND (decl, 0)) == COMPONENT_REF
  && (((TREE_CODE (TREE_TYPE (TREE_OPERAND (decl, 0)))
== REFERENCE_TYPE)
@@ -1646,7 +1646,7 @@ scan_sharing_clauses (tree clauses, omp_context *ctx)
  && TREE_CODE (DECL_SIZE (decl)) != INTEGER_CST)
{
  tree decl2 = DECL_VALUE_EXPR (decl);
- gcc_assert (TREE_CODE (decl2) == INDIRECT_REF);
+ gcc_assert (INDIRECT_REF_P (decl2));
  decl2 = TREE_OPERAND (decl2, 0);
  gcc_assert (DECL_P (decl2));
  install_var_local (decl2, ctx);
@@ -1660,7 +1660,7 @@ scan_sharing_clauses (tree clauses, omp_context *ctx)
  && TREE_CODE (DECL_SIZE (decl)) != INTEGER_CST)
{
  tree decl2 = DECL_VALUE_EXPR (decl);
- gcc_assert (TREE_CODE (decl2) == INDIRECT_REF);
+ gcc_assert (INDIRECT_REF_P (decl2));
  decl2 = TREE_OPERAND (decl2, 0);
  gcc_assert (DECL_P (decl2));
  install_var_field (decl2, true, 3, ctx);
@@ -1802,7 +1802,7 @@ scan_sharing_clauses (tree clauses, omp_context *ctx)
  decl = OMP_CLAUSE_DECL (c);
  if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_HAS_DEVICE_ADDR)
{
- while (TREE_CODE (decl) == INDIRECT_REF
+ while (INDIRECT_REF_P (decl)
 || TREE_CODE (decl) == ARRAY_REF)
decl = TREE_OPERAND (decl, 0);
}
@@ -1815,7 +1815,7 @@ scan_sharing_clauses (tree clauses, omp_context *ctx)
  && is_gimple_omp_offloaded (ctx->stmt))

[PATCH 10/14] c: use _P() defines from tree.h

2023-05-13 Thread Bernhard Reutner-Fischer via Gcc-patches
From: Bernhard Reutner-Fischer 

gcc/c-family/ChangeLog:

* c-ada-spec.cc (has_static_fields): Use _P() defines from tree.h.
(dump_ada_declaration): Ditto.
(dump_ada_structure): Ditto.
* c-common.cc (unsafe_conversion_p): Ditto.
(shorten_compare): Ditto.
(pointer_int_sum): Ditto.
(c_common_truthvalue_conversion): Ditto.
(scalar_to_vector): Ditto.
* c-common.h (gnu_vector_type_p): Ditto.
* c-omp.cc (c_omp_depend_t_p): Ditto.
(c_omp_split_clauses): Ditto.
* c-ubsan.cc (ubsan_instrument_division): Ditto.
* c-warn.cc (conversion_warning): Ditto.
(warnings_for_convert_and_check): Ditto.

gcc/c/ChangeLog:

* c-convert.cc (c_convert): Ditto.
* c-decl.cc (merge_decls): Ditto.
* c-parser.cc (c_parser_omp_clause_reduction): Ditto.
(c_parser_omp_declare_reduction): Ditto.
* c-typeck.cc (build_component_ref): Ditto.
(convert_argument): Ditto.
(pointer_diff): Ditto.
(build_unary_op): Ditto.
(build_c_cast): Ditto.
(build_modify_expr): Ditto.
(store_init_value): Ditto.
(constexpr_init_fits_real_type): Ditto.
(check_constexpr_init): Ditto.
(c_finish_return): Ditto.
(handle_omp_array_sections_1): Ditto.
(c_finish_omp_clauses): Ditto.
* gimple-parser.cc (c_finish_gimple_return): Ditto.

libcc1/ChangeLog:

* libcc1plugin.cc (plugin_float_type): Ditto.
* libcp1plugin.cc (plugin_reactivate_decl): Ditto.
(plugin_get_float_type): Ditto.
---
 gcc/c-family/c-ada-spec.cc |  6 ++---
 gcc/c-family/c-common.cc   | 32 +++
 gcc/c-family/c-common.h|  2 +-
 gcc/c-family/c-omp.cc  |  5 ++--
 gcc/c-family/c-ubsan.cc|  2 +-
 gcc/c-family/c-warn.cc |  6 ++---
 gcc/c/c-convert.cc |  4 +--
 gcc/c/c-decl.cc|  6 ++---
 gcc/c/c-parser.cc  |  4 +--
 gcc/c/c-typeck.cc  | 52 +++---
 gcc/c/gimple-parser.cc |  2 +-
 libcc1/libcc1plugin.cc |  2 +-
 libcc1/libcp1plugin.cc |  4 +--
 13 files changed, 63 insertions(+), 64 deletions(-)

diff --git a/gcc/c-family/c-ada-spec.cc b/gcc/c-family/c-ada-spec.cc
index b50b3877564..050994d8416 100644
--- a/gcc/c-family/c-ada-spec.cc
+++ b/gcc/c-family/c-ada-spec.cc
@@ -1051,7 +1051,7 @@ has_static_fields (const_tree type)
 return false;
 
   for (tree fld = TYPE_FIELDS (type); fld; fld = TREE_CHAIN (fld))
-if (TREE_CODE (fld) == VAR_DECL && DECL_NAME (fld))
+if (VAR_P (fld) && DECL_NAME (fld))
   return true;
 
   return false;
@@ -3244,7 +3244,7 @@ dump_ada_declaration (pretty_printer *buffer, tree t, 
tree type, int spc)
   if (need_indent)
INDENT (spc);
 
-  if ((TREE_CODE (t) == FIELD_DECL || TREE_CODE (t) == VAR_DECL)
+  if ((TREE_CODE (t) == FIELD_DECL || VAR_P (t))
  && DECL_NAME (t))
check_type_name_conflict (buffer, t);
 
@@ -3462,7 +3462,7 @@ dump_ada_structure (pretty_printer *buffer, tree node, 
tree type, bool nested,
   /* Print the static fields of the structure, if any.  */
   for (tree tmp = TYPE_FIELDS (node); tmp; tmp = TREE_CHAIN (tmp))
 {
-  if (TREE_CODE (tmp) == VAR_DECL && DECL_NAME (tmp))
+  if (VAR_P (tmp) && DECL_NAME (tmp))
{
  if (need_semicolon)
{
diff --git a/gcc/c-family/c-common.cc b/gcc/c-family/c-common.cc
index 2b4c82facf7..9c8eed5442a 100644
--- a/gcc/c-family/c-common.cc
+++ b/gcc/c-family/c-common.cc
@@ -1483,7 +1483,7 @@ unsafe_conversion_p (tree type, tree expr, tree result, 
bool check_sign)
 
   /* Warn for real constant that is not an exact integer converted
 to integer type.  */
-  if (TREE_CODE (expr_type) == REAL_TYPE
+  if (SCALAR_FLOAT_TYPE_P (expr_type)
  && TREE_CODE (type) == INTEGER_TYPE)
{
  if (!real_isinteger (TREE_REAL_CST_PTR (expr), TYPE_MODE (expr_type)))
@@ -1508,7 +1508,7 @@ unsafe_conversion_p (tree type, tree expr, tree result, 
bool check_sign)
  else
give_warning = UNSAFE_OTHER;
}
-  else if (TREE_CODE (type) == REAL_TYPE)
+  else if (SCALAR_FLOAT_TYPE_P (type))
{
  /* Warn for an integer constant that does not fit into real type.  */
  if (TREE_CODE (expr_type) == INTEGER_TYPE)
@@ -1519,7 +1519,7 @@ unsafe_conversion_p (tree type, tree expr, tree result, 
bool check_sign)
}
  /* Warn for a real constant that does not fit into a smaller
 real type.  */
- else if (TREE_CODE (expr_type) == REAL_TYPE
+ else if (SCALAR_FLOAT_TYPE_P (expr_type)
   && TYPE_PRECISION (type) < TYPE_PRECISION (expr_type))
{
  REAL_VALUE_TYPE a = TREE_REAL_CST (expr);
@@ -1579,7 +1579,7 @@ unsafe_conversion_p (tree type, tree expr, tree result, 
bool check_sign)
   else
 {
   /* Warn for real types converted 

[PATCH 07/14] d: use _P() defines from tree.h

2023-05-13 Thread Bernhard Reutner-Fischer via Gcc-patches
From: Bernhard Reutner-Fischer 

gcc/d/ChangeLog:

* d-codegen.cc (underlying_complex_expr): Use _P defines from tree.h.
* d-convert.cc (convert): Ditto.
(convert_for_rvalue): Ditto.
---
 gcc/d/d-codegen.cc | 2 +-
 gcc/d/d-convert.cc | 9 -
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/gcc/d/d-codegen.cc b/gcc/d/d-codegen.cc
index 5c6c300ecec..9bae06077b5 100644
--- a/gcc/d/d-codegen.cc
+++ b/gcc/d/d-codegen.cc
@@ -1599,7 +1599,7 @@ underlying_complex_expr (tree type, tree expr)
   /* Build a constructor from the real and imaginary parts.  */
   if (COMPLEX_FLOAT_TYPE_P (TREE_TYPE (expr)) &&
   (!INDIRECT_REF_P (expr)
-   || !CONVERT_EXPR_CODE_P (TREE_CODE (TREE_OPERAND (expr, 0)
+   || !CONVERT_EXPR_P (TREE_OPERAND (expr, 0
 {
   vec  *ve = NULL;
   CONSTRUCTOR_APPEND_ELT (ve, TYPE_FIELDS (type),
diff --git a/gcc/d/d-convert.cc b/gcc/d/d-convert.cc
index 9e7fcd506f8..cdbd69cf012 100644
--- a/gcc/d/d-convert.cc
+++ b/gcc/d/d-convert.cc
@@ -257,7 +257,7 @@ convert (tree type, tree expr)
 return fold_convert (type, expr);
   if (TREE_CODE (TREE_TYPE (expr)) == ERROR_MARK)
 return error_mark_node;
-  if (TREE_CODE (TREE_TYPE (expr)) == VOID_TYPE)
+  if (VOID_TYPE_P (TREE_TYPE (expr)))
 {
   error ("void value not ignored as it ought to be");
   return error_mark_node;
@@ -270,8 +270,7 @@ convert (tree type, tree expr)
 
 case INTEGER_TYPE:
 case ENUMERAL_TYPE:
-  if (TREE_CODE (etype) == POINTER_TYPE
- || TREE_CODE (etype) == REFERENCE_TYPE)
+  if (POINTER_TYPE_P (etype))
{
  if (integer_zerop (e))
return build_int_cst (type, 0);
@@ -300,7 +299,7 @@ convert (tree type, tree expr)
   return fold (convert_to_real (type, e));
 
 case COMPLEX_TYPE:
-  if (TREE_CODE (etype) == REAL_TYPE && TYPE_IMAGINARY_FLOAT (etype))
+  if (SCALAR_FLOAT_TYPE_P (etype) && TYPE_IMAGINARY_FLOAT (etype))
return fold_build2 (COMPLEX_EXPR, type,
build_zero_cst (TREE_TYPE (type)),
convert (TREE_TYPE (type), expr));
@@ -656,7 +655,7 @@ convert_for_rvalue (tree expr, Type *etype, Type *totype)
   && ebtype->ty == TY::Tsarray
   && tbtype->nextOf ()->ty == ebtype->nextOf ()->ty
   && INDIRECT_REF_P (expr)
-  && CONVERT_EXPR_CODE_P (TREE_CODE (TREE_OPERAND (expr, 0)))
+  && CONVERT_EXPR_P (TREE_OPERAND (expr, 0))
   && TREE_CODE (TREE_OPERAND (TREE_OPERAND (expr, 0), 0)) == ADDR_EXPR)
 {
   /* If expression is a vector that was casted to an array either by
-- 
2.30.2



[PATCH 02/14] analyzer: use _P() defines from tree.h

2023-05-13 Thread Bernhard Reutner-Fischer via Gcc-patches
From: Bernhard Reutner-Fischer 

gcc/analyzer/ChangeLog:

* region-model-manager.cc (get_code_for_cast): Use _P defines from
tree.h.
(region_model_manager::get_or_create_cast): Ditto.
(region_model_manager::get_region_for_global): Ditto.
* region-model.cc (region_model::get_lvalue_1): Ditto.
* region.cc (decl_region::maybe_get_constant_value): Ditto.
---
 gcc/analyzer/region-model-manager.cc | 8 
 gcc/analyzer/region-model.cc | 2 +-
 gcc/analyzer/region.cc   | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/gcc/analyzer/region-model-manager.cc 
b/gcc/analyzer/region-model-manager.cc
index fab5bba15d5..3b95e432aba 100644
--- a/gcc/analyzer/region-model-manager.cc
+++ b/gcc/analyzer/region-model-manager.cc
@@ -507,7 +507,7 @@ get_code_for_cast (tree dst_type, tree src_type)
   if (!src_type)
 return NOP_EXPR;
 
-  if (TREE_CODE (src_type) == REAL_TYPE)
+  if (SCALAR_FLOAT_TYPE_P (src_type))
 {
   if (TREE_CODE (dst_type) == INTEGER_TYPE)
return FIX_TRUNC_EXPR;
@@ -531,9 +531,9 @@ region_model_manager::get_or_create_cast (tree type, const 
svalue *arg)
 return arg;
 
   /* Don't attempt to handle casts involving vector types for now.  */
-  if (TREE_CODE (type) == VECTOR_TYPE
+  if (VECTOR_TYPE_P (type)
   || (arg->get_type ()
- && TREE_CODE (arg->get_type ()) == VECTOR_TYPE))
+ && VECTOR_TYPE_P (arg->get_type (
 return get_or_create_unknown_svalue (type);
 
   enum tree_code op = get_code_for_cast (type, arg->get_type ());
@@ -1410,7 +1410,7 @@ region_model_manager::get_region_for_label (tree label)
 const decl_region *
 region_model_manager::get_region_for_global (tree expr)
 {
-  gcc_assert (TREE_CODE (expr) == VAR_DECL);
+  gcc_assert (VAR_P (expr));
 
   decl_region **slot = m_globals_map.get (expr);
   if (slot)
diff --git a/gcc/analyzer/region-model.cc b/gcc/analyzer/region-model.cc
index fb81d43f91b..3bb3df2f063 100644
--- a/gcc/analyzer/region-model.cc
+++ b/gcc/analyzer/region-model.cc
@@ -2092,7 +2092,7 @@ region_model::get_lvalue_1 (path_var pv, 
region_model_context *ctxt) const
   {
gcc_assert (TREE_CODE (expr) == SSA_NAME
|| TREE_CODE (expr) == PARM_DECL
-   || TREE_CODE (expr) == VAR_DECL
+   || VAR_P (expr)
|| TREE_CODE (expr) == RESULT_DECL);
 
int stack_index = pv.m_stack_depth;
diff --git a/gcc/analyzer/region.cc b/gcc/analyzer/region.cc
index a18bfa50d09..8f0eb569b33 100644
--- a/gcc/analyzer/region.cc
+++ b/gcc/analyzer/region.cc
@@ -1162,7 +1162,7 @@ decl_region::get_stack_depth () const
 const svalue *
 decl_region::maybe_get_constant_value (region_model_manager *mgr) const
 {
-  if (TREE_CODE (m_decl) == VAR_DECL
+  if (VAR_P (m_decl)
   && DECL_IN_CONSTANT_POOL (m_decl)
   && DECL_INITIAL (m_decl)
   && TREE_CODE (DECL_INITIAL (m_decl)) == CONSTRUCTOR)
-- 
2.30.2



[Bug analyzer/109851] New: False positive va_arg when iterating through format string with for-loop

2023-05-13 Thread nvinson234+gcc-bugs at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109851

Bug ID: 109851
   Summary: False positive va_arg when iterating through format
string with for-loop
   Product: gcc
   Version: 13.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: analyzer
  Assignee: dmalcolm at gcc dot gnu.org
  Reporter: nvinson234+gcc-bugs at gmail dot com
  Target Milestone: ---

Created attachment 55081
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55081=edit
analzyer warning output

When compiling the following code:

  #include
  #include
  #include

  void foo(char *fmt, ...) {
  int i = 0;
  char c;
  va_list ap;
  va_start(ap, fmt);

  for (i = 0; (c = fmt[i]) != 0; i++) {
  c = fmt[i];
  if (c == '%') {
  printf("Saw %%");
  }
  if (c == 'd') {
  i = va_arg(ap, int);
  }
  }
  va_end(ap);
  }

  int main(int argc, char **argv) {
  foo("%s.lt", argv[0]);
  return 0;
  }


with the command: gcc -O2 -fanalyzer test.c

The analyzer gives the warning:
test.c:17:15: warning: ‘va_arg’ expected ‘int’ but received ‘char *’ for
variadic argument 1 of ‘ap’

However, the condition "c == 'd'" is never true and va_arg() is never called.

This is a reduced case based on the lemon_vsnprintf() code found in
sqlite-3.41.2'a tool/lemon.c.

Full warning output attached.

[Bug libgcc/109670] [13/14 regression] Exception handling broken for 32-bit Windows

2023-05-13 Thread reiter.christoph at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109670

--- Comment #15 from Christoph Reiter  ---
(In reply to Thomas Neumann from comment #12)
> Created attachment 55037 [details]
> radix sort fix
> 
> I could reproduce the problem, the radix sort did not behave correctly when
> we ran out of bits, which can happen on 32bit platforms. The attached patch
> fixes the problem.

I can confirm that this fixes the issue for me.

[Bug c/87379] Warn about function pointer casts which differ in variadic-ness [-Wcast-variadic-function-type]

2023-05-13 Thread sjames at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87379

--- Comment #3 from Sam James  ---
This is a bit of (not entirely, but a lot of) what I was reaching for in
PR109835. I knew there was a ppc64 example in my head but I couldn't find it.

It's also a good argument for just doing it entirely for func. ptrs (rather
than special-casing it more), IMO, given the cases I've listed over there.

[Bug c/109835] -Wincompatible-function-pointer-types as a subset of -Wincompatible-pointer-types?

2023-05-13 Thread sjames at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109835

--- Comment #4 from Sam James  ---
(In reply to Eric Gallager from comment #3)
> I thought that there was already a separate bug for this, but it turns out
> that I was thinking of bug 87379, which is for something different...

Good catch. I think that'd actually address some (not all, ofc) of the concerns
I have about these.

[Bug c++/109850] ICE compiling ccache 4.8

2023-05-13 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109850

--- Comment #4 from Andrew Pinski  ---
And yes it is a dup:
void
LocalStorage::recompress 
{

[&](const auto& l1_index, const auto& l1_progress_receiver) {

[&](const auto& l2_index, const auto& l2_progress_receiver) {
  [] { struct ... FMT_COMPILE_STRING

[Bug c++/109241] [12/13 Regression] ICE Segmentation fault for statement expression with a local type inside inside a generic lambda inside a generic lambda since r13-6722-gb323f52ccf966800

2023-05-13 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109241

Andrew Pinski  changed:

   What|Removed |Added

 CC||psmith at gnu dot org

--- Comment #7 from Andrew Pinski  ---
*** Bug 109850 has been marked as a duplicate of this bug. ***

[Bug c++/109850] ICE compiling ccache 4.8

2023-05-13 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109850

Andrew Pinski  changed:

   What|Removed |Added

 Resolution|--- |DUPLICATE
 Status|UNCONFIRMED |RESOLVED

--- Comment #3 from Andrew Pinski  ---
Dup of bug 109241.

*** This bug has been marked as a duplicate of bug 109241 ***

[Bug c++/109241] [12/13 Regression] ICE Segmentation fault for statement expression with a local type inside inside a generic lambda inside a generic lambda since r13-6722-gb323f52ccf966800

2023-05-13 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109241

Andrew Pinski  changed:

   What|Removed |Added

  Known to fail||12.3.0, 13.0
   Target Milestone|13.0|12.4
  Known to work||12.2.0

[Bug c++/109850] ICE compiling ccache 4.8

2023-05-13 Thread psmith at gnu dot org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109850

--- Comment #2 from Paul Smith  ---
I don't know if this is of any use but I ran under valgrind and get this
result:

==3019683== Command:
/data/src/build/x86_64-linux/cc/unknown/bin/../libexec/gcc/x86_64-unknown-linux-gnu/12.3.0/cc1plus
-fpreprocessed LocalStorage.i -quiet -dumpbase LocalStorage.i -dumpbase-ext .i
-m64 -mtune=generic -march=x86-64 -o /tmp/ccaQvBYi.s
==3019683== 
==3019683== Invalid read of size 4
==3019683==at 0x7B5503: ??? (in
/data/src/build/x86_64-linux/cc/unknown/libexec/gcc/x86_64-unknown-linux-gnu/12.3.0/cc1plus)
==3019683==by 0x1390609: walk_tree_1(tree_node**, tree_node*
(*)(tree_node**, int*, void*), void*, hash_set >*, tree_node* (*)(tree_node**, int*,
tree_node* (*)(tree_node**, int*, void*), void*, hash_set >*)) (in
/data/src/build/x86_64-linux/cc/unknown/libexec/gcc/x86_64-unknown-linux-gnu/12.3.0/cc1plus)
==3019683==by 0x1390A11: walk_tree_1(tree_node**, tree_node*
(*)(tree_node**, int*, void*), void*, hash_set >*, tree_node* (*)(tree_node**, int*,
tree_node* (*)(tree_node**, int*, void*), void*, hash_set >*)) (in
/data/src/build/x86_64-linux/cc/unknown/libexec/gcc/x86_64-unknown-linux-gnu/12.3.0/cc1plus)
==3019683==by 0x148A6C3: ??? (in
/data/src/build/x86_64-linux/cc/unknown/libexec/gcc/x86_64-unknown-linux-gnu/12.3.0/cc1plus)
==3019683==by 0x1390609: walk_tree_1(tree_node**, tree_node*
(*)(tree_node**, int*, void*), void*, hash_set >*, tree_node* (*)(tree_node**, int*,
tree_node* (*)(tree_node**, int*, void*), void*, hash_set >*)) (in
/data/src/build/x86_64-linux/cc/unknown/libexec/gcc/x86_64-unknown-linux-gnu/12.3.0/cc1plus)
==3019683==by 0x13906DD: walk_tree_1(tree_node**, tree_node*
(*)(tree_node**, int*, void*), void*, hash_set >*, tree_node* (*)(tree_node**, int*,
tree_node* (*)(tree_node**, int*, void*), void*, hash_set >*)) (in
/data/src/build/x86_64-linux/cc/unknown/libexec/gcc/x86_64-unknown-linux-gnu/12.3.0/cc1plus)
==3019683==by 0x1390730: walk_tree_1(tree_node**, tree_node*
(*)(tree_node**, int*, void*), void*, hash_set >*, tree_node* (*)(tree_node**, int*,
tree_node* (*)(tree_node**, int*, void*), void*, hash_set >*)) (in
/data/src/build/x86_64-linux/cc/unknown/libexec/gcc/x86_64-unknown-linux-gnu/12.3.0/cc1plus)
==3019683==by 0x139096F: walk_tree_1(tree_node**, tree_node*
(*)(tree_node**, int*, void*), void*, hash_set >*, tree_node* (*)(tree_node**, int*,
tree_node* (*)(tree_node**, int*, void*), void*, hash_set >*)) (in
/data/src/build/x86_64-linux/cc/unknown/libexec/gcc/x86_64-unknown-linux-gnu/12.3.0/cc1plus)
==3019683==by 0x1484986: check_for_bare_parameter_packs(tree_node*,
unsigned int) (in
/data/src/build/x86_64-linux/cc/unknown/libexec/gcc/x86_64-unknown-linux-gnu/12.3.0/cc1plus)
==3019683==by 0x157004A: finish_expr_stmt(tree_node*) (in
/data/src/build/x86_64-linux/cc/unknown/libexec/gcc/x86_64-unknown-linux-gnu/12.3.0/cc1plus)
==3019683==by 0x1689186: tsubst_expr(tree_node*, tree_node*, int,
tree_node*, bool) (in
/data/src/build/x86_64-linux/cc/unknown/libexec/gcc/x86_64-unknown-linux-gnu/12.3.0/cc1plus)
==3019683==by 0x1689087: tsubst_expr(tree_node*, tree_node*, int,
tree_node*, bool) (in
/data/src/build/x86_64-linux/cc/unknown/libexec/gcc/x86_64-unknown-linux-gnu/12.3.0/cc1plus)
==3019683==  Address 0x5c is not stack'd, malloc'd or (recently) free'd
==3019683==

[Bug middle-end/109849] suboptimal code for vector walking loop

2023-05-13 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109849

--- Comment #2 from Andrew Pinski  ---
(In reply to Jan Hubicka from comment #0)
> saving an instruction. Why we do not move stack+8 updating out of the loop?

Maybe because of a clobber:
  cur$second_5 = MEM[(const struct pairD.26349 &)_7 +
18446744073709551608].secondD.27577;
  # PT = nonlocal escaped 
  _4 = _7 + 18446744073709551608;
  # .MEM_9 = VDEF <.MEM_1>
  stackD.26352.D.27437._M_implD.26667.D.26744._M_finishD.26670 = _4;
  # .MEM_10 = VDEF <.MEM_9>
  MEM[(struct pairD.26349 *)_7 + -8B] ={v} {CLOBBER};

gcc-13-20230513 is now available

2023-05-13 Thread GCC Administrator via Gcc
Snapshot gcc-13-20230513 is now available on
  https://gcc.gnu.org/pub/gcc/snapshots/13-20230513/
and on various mirrors, see http://gcc.gnu.org/mirrors.html for details.

This snapshot has been generated from the GCC 13 git branch
with the following options: git://gcc.gnu.org/git/gcc.git branch 
releases/gcc-13 revision 251aae90d76d0f53eecb119d0afa2e20008feba9

You'll find:

 gcc-13-20230513.tar.xz   Complete GCC

  SHA256=017aed7975deee6148599a3f0ce39f8e7b2541bef10c9e5e7b090e6958f53f37
  SHA1=951b1647e73bb8d45624fb38646c27e355c68e2a

Diffs from 13-20230506 are available in the diffs/ subdirectory.

When a particular snapshot is ready for public consumption the LATEST-13
link is updated and a message is sent to the gcc list.  Please do not use
a snapshot before it has been announced that way.


[Bug c++/109850] ICE compiling ccache 4.8

2023-05-13 Thread psmith at gnu dot org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109850

Paul Smith  changed:

   What|Removed |Added

 CC||psmith at gnu dot org

--- Comment #1 from Paul Smith  ---
Created attachment 55080
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55080=edit
LocalStorage.i compressed

[Bug middle-end/109849] suboptimal code for vector walking loop

2023-05-13 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109849

--- Comment #1 from Andrew Pinski  ---
Actually why didn't we copy the loop header in the first place?

[Bug c++/109850] New: ICE compiling ccache 4.8

2023-05-13 Thread psmith at gnu dot org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109850

Bug ID: 109850
   Summary: ICE compiling ccache 4.8
   Product: gcc
   Version: 12.3.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: c++
  Assignee: unassigned at gcc dot gnu.org
  Reporter: psmith at gnu dot org
  Target Milestone: ---

I've started working with GCC 12.3.0 I've built myself and I've gotten an ICE
trying to compile ccache 4.8.  The preprocessor output is attached.  I'm
building using a sysroot from a Rocky Linux 8.4 x86_64 system with glibc 2.28. 
I'm using my own binutils 2.40.

I was able to reduce the command line to just: g++ -o LocalStorage.o -c
LocalStorage.i

I attached the .i file.

Output from my build:

$ /data/src/tooldir/bin/x86_64-tools-linux-gnu-g++ -o LocalStorage.o -c
LocalStorage.i
/data/src/ccache/ccache-4.8/src/storage/local/LocalStorage.cpp: In
instantiation of 'storage::local::LocalStorage::recompress(std::optional, uint32_t, const storage::local::ProgressReceiver&):: [with auto:39 = unsigned char; auto:40 =
std::function]':
/data/src/build/x86_64-linux/cc/unknown/x86_64-unknown-linux-gnu/include/c++/12.3.0/type_traits:2559:26:
  required by substitution of 'template static
std::__result_of_success()((declval<_Args>)()...)),
std::__invoke_other> std::__result_of_other_impl::_S_test(int) [with _Fn =
storage::local::LocalStorage::recompress(std::optional, uint32_t,
const storage::local::ProgressReceiver&)::&; _Args = {unsigned char, const std::function&}]'
/data/src/build/x86_64-linux/cc/unknown/x86_64-unknown-linux-gnu/include/c++/12.3.0/type_traits:2570:55:
  required from 'struct std::__result_of_impl, uint32_t,
const storage::local::ProgressReceiver&)::&, unsigned char, const std::function&>'
/data/src/build/x86_64-linux/cc/unknown/x86_64-unknown-linux-gnu/include/c++/12.3.0/bits/std_function.h:348:9:
  recursively required by substitution of 'template
struct std::__is_invocable_impl<_Result, _Ret, true, std::__void_t > [with _Result =
std::__invoke_result, uint32_t, const storage::local::ProgressReceiver&)::&, unsigned char, const
std::function&>; _Ret = void]'
/data/src/build/x86_64-linux/cc/unknown/x86_64-unknown-linux-gnu/include/c++/12.3.0/bits/std_function.h:348:9:
  required from 'struct std::function&)>::_Callable, uint32_t, const storage::local::ProgressReceiver&)::,
storage::local::LocalStorage::recompress(std::optional, uint32_t,
const storage::local::ProgressReceiver&)::,
std::__invoke_result, uint32_t, const storage::local::ProgressReceiver&)::&, unsigned char, const std::function&>
>'
/data/src/build/x86_64-linux/cc/unknown/x86_64-unknown-linux-gnu/include/c++/12.3.0/bits/std_function.h:353:8:
  required by substitution of 'template
template using _Requires =
std::__enable_if_t<_Cond::value, _Tp> [with _Cond = std::function&)>::_Callable, uint32_t, const storage::local::ProgressReceiver&)::,
storage::local::LocalStorage::recompress(std::optional, uint32_t,
const storage::local::ProgressReceiver&)::,
std::__invoke_result, uint32_t, const storage::local::ProgressReceiver&)::&, unsigned char, const std::function&>
>; _Tp = void; _Res = void; _ArgTypes = {unsigned char, const
std::function&}]'
/data/src/build/x86_64-linux/cc/unknown/x86_64-unknown-linux-gnu/include/c++/12.3.0/bits/std_function.h:434:9:
  required by substitution of 'template
std::function&)>::function(_Functor&&) [with _Functor =
storage::local::LocalStorage::recompress(std::optional, uint32_t,
const storage::local::ProgressReceiver&)::; _Constraints = ]'
/data/src/ccache/ccache-4.8/src/storage/local/LocalStorage.cpp:701:24:  
required from here
/data/src/ccache/ccache-4.8/src/storage/local/LocalStorage.cpp:710:44: internal
compiler error: Segmentation fault
  710 | LOG("Failed to acquire content lock for {}/{}", l1_index,
l2_index);
  |^~~
0x7f1399b2c08f ???
   
/build/glibc-SzIz7B/glibc-2.31/signal/../sysdeps/unix/sysv/linux/x86_64/sigaction.c:0
0x7f1399b0d082 __libc_start_main
../csu/libc-start.c:308


I tried to use -freport-bug but it said "The bug is not reproducible, so it is
likely a hardware or OS problem."  But I don't think it's a hardware or OS
problem.  It could be related to how I compiled GCC maybe?  The crash is
completely repeatable on my system.

[Bug tree-optimization/109829] Optimizing __builtin_signbit(x) ? -x : x or abs for FP

2023-05-13 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109829

--- Comment #8 from Andrew Pinski  ---
Created attachment 55079
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55079=edit
Patch which I am testing

[Bug fortran/109846] [rejects valid] Pointer-valued function reference rejected as actual argument

2023-05-13 Thread neil.n.carlson at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109846

--- Comment #2 from Neil Carlson  ---
Amusing! I have a regression in 13.1 (which I need to create a reproducer for)
where the workaround for a segfault is to use a RESULT variable -- just the
opposite :-)

[Bug middle-end/109849] New: suboptimal code for vector walking loop

2023-05-13 Thread hubicka at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109849

Bug ID: 109849
   Summary: suboptimal code for vector walking loop
   Product: gcc
   Version: 13.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: middle-end
  Assignee: unassigned at gcc dot gnu.org
  Reporter: hubicka at gcc dot gnu.org
  Target Milestone: ---

jan@localhost:/tmp> cat t.C
#include 
typedef unsigned int uint32_t;
std::vector> stack;
void
test()
{
while (!stack.empty()) {
std::pair cur = stack.back();
stack.pop_back();
if (cur.second)
break;
}
}
jan@localhost:/tmp> gcc t.C -O3 -S 

yields to:

_Z4testv:
.LFB1264:
.cfi_startproc
movqstack(%rip), %rcx
movqstack+8(%rip), %rax
jmp .L5
.p2align 4,,10
.p2align 3
.L6:
movl-4(%rax), %edx
subq$8, %rax
movq%rax, stack+8(%rip)
testl   %edx, %edx
jne .L4
.L5:
cmpq%rax, %rcx
jne .L6
.L4:
ret

We really should order the basic blocks putting cmpq before L6 saving a jump.
Moreover clang does

.p2align4, 0x90
.LBB1_1:# =>This Inner Loop Header: Depth=1
cmpq%rax, %rcx
je  .LBB1_3
# %bb.2:#   in Loop: Header=BB1_1 Depth=1
cmpl$0, -4(%rcx)
leaq-8(%rcx), %rcx
movq%rcx, stack+8(%rip)
je  .LBB1_1
.LBB1_3:
retq

saving an instruction. Why we do not move stack+8 updating out of the loop?

[Bug fortran/109846] [rejects valid] Pointer-valued function reference rejected as actual argument

2023-05-13 Thread kargl at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109846

kargl at gcc dot gnu.org changed:

   What|Removed |Added

   Priority|P3  |P4
 CC||kargl at gcc dot gnu.org

--- Comment #1 from kargl at gcc dot gnu.org ---
Confirmed.

Workaround seems to be to not use a RESULT variable.
This change seems to work

  function sublist(this)
class(parameter_list), intent(inout) :: this
class(parameter_list), pointer :: sublist
allocate(sublist)
  end function

[Bug tree-optimization/109848] New: [14 Regression] Recent change causing testsuite ICE on csky port

2023-05-13 Thread law at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109848

Bug ID: 109848
   Summary: [14 Regression] Recent change causing testsuite ICE on
csky port
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: law at gcc dot gnu.org
  Target Milestone: ---

This patch:

commit cc0e22b3f25d4b2a326322bce711179c02377e6c
Author: Richard Biener 
Date:   Fri May 12 13:43:27 2023 +0200

tree-optimization/64731 - extend store-from CTOR lowering to TARGET_MEM_REF

The following also covers TARGET_MEM_REF when decomposing stores from
CTORs to supported elementwise operations.  This avoids spilling
and cleans up after vector lowering which doesn't touch loads or
stores.  It also mimics what we already do for loads.

PR tree-optimization/64731
* tree-ssa-forwprop.cc (pass_forwprop::execute): Also
handle TARGET_MEM_REF destinations of stores from vector
CTORs.

* gcc.target/i386/pr64731.c: New testcase.


Is causing the csky port to abort in forwprop with an verify_ssa failure
FAIL: gcc.dg/torture/pr52407.c   -O2  (internal compiler error: verify_ssa
failed)
FAIL: gcc.dg/torture/pr52407.c   -O2  (test for excess errors)
Excess errors:
/home/jlaw/test/gcc/gcc/testsuite/gcc.dg/torture/pr52407.c:22:1: error:
definition in block 3 follows the use
for SSA_NAME: _38 in statement:
_24 = [(vl_t *)_38];
during GIMPLE pass: forwprop
/home/jlaw/test/gcc/gcc/testsuite/gcc.dg/torture/pr52407.c:22:1: internal
compiler error: verify_ssa failed
0x11a93bf verify_ssa(bool, bool)
/home/jlaw/test/gcc/gcc/tree-ssa.cc:1203
0xe5f8a5 execute_function_todo
/home/jlaw/test/gcc/gcc/passes.cc:2105
0xe5e4de do_per_function
/home/jlaw/test/gcc/gcc/passes.cc:1694
0xe5fa4e execute_todo
/home/jlaw/test/gcc/gcc/passes.cc:2152


Testsuite is gcc.dg/torture/pr52407 can can be seen with just a cross compiler.

[Bug analyzer/109847] New: -Wanalyzer-out-of-bounds false positive with Emacs tagged pointers

2023-05-13 Thread eggert at cs dot ucla.edu via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109847

Bug ID: 109847
   Summary: -Wanalyzer-out-of-bounds false positive with Emacs
tagged pointers
   Product: gcc
   Version: 13.1.1
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: analyzer
  Assignee: dmalcolm at gcc dot gnu.org
  Reporter: eggert at cs dot ucla.edu
  Target Milestone: ---

Created attachment 55078
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55078=edit
compile with 'gcc -O2 -fanalyzer' to illustrate the false positive

I ran into this problem when compiling GNU Emacs with GCC 13.1.1 20230426 (Red
Hat 13.1.1-1) on x86-64. The attached file contains stripped-down source code
to illustrate the problem. Compile it with:

gcc -O2 -fanalyzer -S analyzer-bounds-bug.i

The output is shown below. This output is incorrect, since it is complaining
about the access to the 'size' member, but that access is never executed as the
previous condition '! (((unsigned) (long) a - 5) & 7)' is false.

If you change line 51 from 'CHECK_STRING (buffer_or_name);' to 'if (0)
CHECK_STRING (buffer_or_name);' the warning goes away. But line 51 is executed
after the line being warned about. It looks like line 51 is confusing the
analyzer into thinking that line 50 can be executed in an impossible way.

As can be seen below, GCC also issues an incorrect
-Wanalyzer-use-of-uninitialized-value diagnostic, but since that may be
cascading from the earlier bug I am not reporting it separately.


In function ‘PSEUDOVECTORP’,
inlined from ‘BUFFERP’ at analyzer-bounds-bug.i:44:10,
inlined from ‘Fget_buffer’ at analyzer-bounds-bug.i:50:9:
analyzer-bounds-bug.i:39:50: warning: stack-based buffer under-read [CWE-127]
[-Wanalyzer-out-of-bounds]
   39 |   && ((struct buffer *) ((char *) a - 5))->size == code);
  |  ^~
  ‘init_buffer’: events 1-2
|
|   56 | init_buffer (void)
|  | ^~~
|  | |
|  | (1) entry to ‘init_buffer’
|..
|   60 |   Fget_buffer (scratch);
|  |   ~
|  |   |
|  |   (2) calling ‘Fget_buffer’ from ‘init_buffer’
|
+--> ‘Fget_buffer’: events 3-4
   |
   |   48 | Fget_buffer (Lisp_Object buffer_or_name)
   |  | ^~~
   |  | |
   |  | (3) entry to ‘Fget_buffer’
   |   49 | {
   |   50 |   if (! BUFFERP (buffer_or_name))
   |  | ~
   |  | |
   |  | (4) inlined call to ‘BUFFERP’ from ‘Fget_buffer’
   |
   +--> ‘BUFFERP’: event 5
  |
  |   44 |   return PSEUDOVECTORP (a, 13);
  |  |  ^
  |  |  |
  |  |  (5) inlined call to ‘PSEUDOVECTORP’ from
‘BUFFERP’
  |
  +--> ‘PSEUDOVECTORP’: events 6-8
 |
 |   38 |   return (! (((unsigned) (long) a - 5) & 7)
 |  |  ~~
 |   39 |   && ((struct buffer *) ((char *) a -
5))->size == code);
 |  |  
^~
 |  |   |  
   |
 |  |   |  
   (7) ...to here
 |  |   (6) following ‘true’ branch... 
   (8) out-of-bounds read at byte -1 but ‘’ starts at byte 0
 |
analyzer-bounds-bug.i:39:50: warning: use of uninitialized value ‘((struct
buffer *)((char *)buffer_or_name + 3))[2305843009213693951].size’ [CWE-457]
[-Wanalyzer-use-of-uninitialized-value]
   39 |   && ((struct buffer *) ((char *) a - 5))->size == code);
  |  ^~
  ‘init_buffer’: events 1-3
|
|   56 | init_buffer (void)
|  | ^~~
|  | |
|  | (1) entry to ‘init_buffer’
|..
|   59 | (&(struct Lisp_String) {{{9, "*scratch*"}}}, 4);
|  |~
|  ||
|  |(2) region created on stack here
|   60 |   Fget_buffer (scratch);
|  |   ~
|  |   |
|  |   (3) calling ‘Fget_buffer’ from ‘init_buffer’
|
+--> ‘Fget_buffer’: events 4-5
   |
   |   48 | Fget_buffer (Lisp_Object buffer_or_name)
   |  | ^~~
   |  | |
   |  | (4) entry to ‘Fget_buffer’
   |   49 | {
   |   50 |   if (! BUFFERP (buffer_or_name))
   |  | ~
 

[Bug fortran/109846] New: [rejects valid] Pointer-valued function reference rejected as actual argument

2023-05-13 Thread neil.n.carlson at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109846

Bug ID: 109846
   Summary: [rejects valid] Pointer-valued function reference
rejected as actual argument
   Product: gcc
   Version: 13.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: fortran
  Assignee: unassigned at gcc dot gnu.org
  Reporter: neil.n.carlson at gmail dot com
  Target Milestone: ---

Gfortran rejects the following example.

module foo
  type :: parameter_list
  contains
procedure :: sublist
  end type
contains
  function sublist(this) result(slist)
class(parameter_list), intent(inout) :: this
class(parameter_list), pointer :: slist
allocate(slist)
  end function
end module

program example
  use foo
  type(parameter_list) :: plist
  call sub(plist%sublist())
contains
  subroutine sub(plist)
type(parameter_list), intent(inout) :: plist
  end subroutine
end program

With this error:

   17 |   call sub(plist%sublist())
  |   1
Error: ‘sublist’ in variable definition context (actual argument to INTENT =
OUT/INOUT) at (1) is not a variable

It is accepted by both Intel OneAPI and NAG compilers. The sublist function
returns
a polymorphic pointer, which seems to be the source of the error. If it is
modified
to return a non-polymorphic pointer the example compiles without error.
Alternatively,
if the dummy argument intent is changed to intent(in) it also compiles without
error.

It is valid for a class(parameter_list) variable to be the actual argument for
a
type(parameter_list), intent(inout) dummy argument. So in light of 9.2/C902
(2018)
I think this is a gfortran bug.

[Bug c++/106943] GCC building clang/llvm with LTO flags causes ICE in clang

2023-05-13 Thread xry111 at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106943

Xi Ruoyao  changed:

   What|Removed |Added

 Resolution|--- |MOVED
 Status|WAITING |RESOLVED
URL||https://github.com/llvm/llv
   ||m-project/commit/94f7c961c7
   ||8d8fdbc05898cfbbf88094de45c
   ||1ad

--- Comment #33 from Xi Ruoyao  ---
-fno-lifetime-dse has been added into LLVM building system as a workaround.

[Bug libfortran/107068] Run-time error when reading logical arrays with a namelist

2023-05-13 Thread jvdelisle at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107068

Jerry DeLisle  changed:

   What|Removed |Added

 CC||jvdelisle at gcc dot gnu.org
   Assignee|unassigned at gcc dot gnu.org  |jvdelisle at gcc dot 
gnu.org

--- Comment #5 from Jerry DeLisle  ---
I will get looking at this since it is namelist related.

[Bug debug/109805] LTO affecting -fdebug-prefix-map

2023-05-13 Thread sergiodj at sergiodj dot net via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109805

--- Comment #9 from Sergio Durigan Junior  ---
at(In reply to Richard Biener from comment #8)
> This works for me.  The consistency check is not fully implemented and
> instead
> of passing down no -fdebug-prefix-map the patch passes the first but warns:
>
> > ./xgcc -B. t.o t2.o -o t
> lto-wrapper: warning: option
> -fdebug-prefix-map=/home/rguenther/obj-trunk-g/gcc=/bbb with different
> values, using /home/rguenther/obj-trunk-g/gcc=/aaa
>
> to make consistency checking work we need to record -fcanon-prefix-map
> and the full set of -f{file,debug}-prefix-map options in order (I think
> file and debug variants can be considered the same) of the first TU and
> compare that to each of the following TUs.

Thanks a lot for the patch.  I tried it locally, and it indeed works for the
simple example I posted in the description of this bug.  However, for some
reason it doesn't seem to make a difference for the vim compilation.  I'm still
seeing a directory table like the following:

Directory table:
  [path(line_strp)]
 0 /home/ubuntu/vim/vim-9.0.1378/src/vim-basic (0)
 1 /usr/include/x86_64-linux-gnu/bits (57)
 2 /usr/include (92)

whereas if I pass -fdebug-prefix-map to LDFLAGS, the directory table becomes:

Directory table:
  [path(line_strp)]
 0 /usr/src/vim-2:9.0.1378-2ubuntu2~ppa1/src/vim-basic (0)
 1 /usr/include/x86_64-linux-gnu/bits (65)
 2 /usr/include (100)

which is what I expected to see.

> Note a link-time specified option will simply ignore all options from the
> compile-time (but only for the link-time unit, the compile-time debug info
> has already been generated with the originally specified options).

FWIW, I think this bug is related to #108534 (and the related discussion at
https://gcc.gnu.org/pipermail/gcc-patches/2022-November/606205.html).

[Bug middle-end/109845] Addition overflow/carry flag unnecessarily put in a temporary register

2023-05-13 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109845

Andrew Pinski  changed:

   What|Removed |Added

   Last reconfirmed||2023-05-13
 Status|UNCONFIRMED |NEW
   Severity|normal  |enhancement
  Component|rtl-optimization|middle-end
   Keywords||missed-optimization
 Ever confirmed|0   |1

--- Comment #2 from Andrew Pinski  ---
So the difference between good1 and bad1 at the gimple level is the order of
operands of the bit_ior:
good1:

  ov_8 = _13 != 0;
  _9 = x_2(D) != 0;
  _10 = ov_8 | _9;
  if (_10 != 0)

bad1:
  ov_7 = _13 != 0;
  _1 = x_8(D) != 0;
  _2 = _1 | ov_7;
  if (_2 != 0)

[Bug rtl-optimization/109845] Addition overflow/carry flag unnecessarily put in a temporary register

2023-05-13 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109845

--- Comment #1 from Andrew Pinski  ---
Created attachment 55077
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55077=edit
full testcase

Next time please attach the full compilable testcase or paste it inline rather
than just including a godbolt link.

[Bug rtl-optimization/109845] New: Addition overflow/carry flag unnecessarily put in a temporary register

2023-05-13 Thread chfast at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109845

Bug ID: 109845
   Summary: Addition overflow/carry flag unnecessarily put in a
temporary register
   Product: gcc
   Version: 13.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: rtl-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: chfast at gmail dot com
  Target Milestone: ---

When we have an addition and an overflow check and the overflow flag is
combined with some other condition the codegen may generate variant when the
overflow flag is temporary register.

unsigned s = y + z;
_Bool ov = s < y;

if (x || ov) 
return;

This produces

add esi, edx
setcal
testedi, edi
jne .L1
testeax, eax
jne .L1

while it could be

add esi, edx
jc  .L6
testedi, edi
jne .L6


There are easy workaround to the C code which make the assembly optimal:

1. Change the order of checks 
if (ov || x)

2. Split if into two
if (x)
return;
if (ov) 
return;

https://godbolt.org/z/rxsrnhPdc

[Bug rtl-optimization/49054] useless cmp+jmp generated for switch when "default:" is unreachable

2023-05-13 Thread chfast at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=49054

Paweł Bylica  changed:

   What|Removed |Added

 CC||chfast at gmail dot com

--- Comment #7 from Paweł Bylica  ---
GCC 13 generates optimal decision tree for the mentioned modified case.

if id == 3:
i()
elif id <= 3:
if id == 0:
f()
else:  # 1
g()
else:
if id == 4:
j()
else:  # 23456
h()

https://godbolt.org/z/9j6b88qKE

So I think this issue is fixed.

[Bug target/109844] Unnecessary basic block with single jmp instruction

2023-05-13 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109844

Andrew Pinski  changed:

   What|Removed |Added

 Resolution|--- |DUPLICATE
 Status|UNCONFIRMED |RESOLVED

--- Comment #1 from Andrew Pinski  ---
Dup of much older issue, PR 47253.

*** This bug has been marked as a duplicate of bug 47253 ***

[Bug target/47253] Conditional jump to tail function is not generated

2023-05-13 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47253

Andrew Pinski  changed:

   What|Removed |Added

 CC||chfast at gmail dot com

--- Comment #7 from Andrew Pinski  ---
*** Bug 109844 has been marked as a duplicate of this bug. ***

[Bug middle-end/109844] New: Unnecessary basic block with single jmp instruction

2023-05-13 Thread chfast at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109844

Bug ID: 109844
   Summary: Unnecessary basic block with single jmp instruction
   Product: gcc
   Version: 13.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: middle-end
  Assignee: unassigned at gcc dot gnu.org
  Reporter: chfast at gmail dot com
  Target Milestone: ---

The code

void err(void);

void merge_bb(int y) {
if (y) 
return err();
}

is

merge_bb:
testedi, edi
jne .L4
ret
.L4:
jmp err


but could be

merge_bb:
testedi, edi
jne err
ret

https://godbolt.org/z/eafPa4o4T

Re: [PATCH] libffi: fix handling of homogeneous float128 structs [PR109447]

2023-05-13 Thread Peter Bergner via Gcc-patches
On 5/10/23 2:34 AM, Andreas Schwab wrote:
> On Mai 09 2023, Peter Bergner via Gcc-patches wrote:
>> I'm sorry to be dense, but can you point to the specific line?  In my
>> $GCC_BUILD/Makefile, the only mention of LD_LIBRARY_PATH is:
>>
>>   RPATH_ENVVAR = LD_LIBRARY_PATH
>>
>> ...so that isn't setting LD_LIBRARY_PATH, but using it.
> 
> Have you considered searching for uses of RPATH_ENVVAR?

Ah, I misread that as RPATH_ENVVAR = $LD_LIBRARY_PATH and was
expecting to see "export LD_LIBRARY_PATH=..." in the code.
Thanks for the pointer!

Peter




[Bug tree-optimization/109843] New: signbit comparisons -> copysign optimization

2023-05-13 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109843

Bug ID: 109843
   Summary: signbit comparisons -> copysign optimization
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Keywords: missed-optimization
  Severity: enhancement
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---

float copysign1(float  x, float y)
{
bool t = __builtin_signbit(x) == 0;
bool t1 = __builtin_signbit(y) == 0;
return (t == t1) ? y : -y;
}
float copysign2(float  x, float y)
{
bool t = __builtin_signbit(x) != 0;
bool t1 = __builtin_signbit(y) != 0;
return (t == t1) ? y : -y;
}
float copysign3(float  x, float y)
{
bool t = __builtin_signbit(x) != 0;
bool t1 = __builtin_signbit(y) == 0;
return (t != t1) ? y : -y;
}
float copysign4(float  x, float y)
{
bool t = __builtin_signbit(x) == 0;
bool t1 = __builtin_signbit(y) != 0;
return (t != t1) ? y : -y;
}
float copysign5(float  x, float y)
{
return __builtin_copysignf(x, y);
}

These all should end up being the same code.
Hopefully I didn't mess these up.

[Bug tree-optimization/109829] Optimizing __builtin_signbit(x) ? -x : x or abs for FP

2023-05-13 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109829

--- Comment #7 from Andrew Pinski  ---
(In reply to Andrew Pinski from comment #6)
> I need to double check if == 1 will show up here though.

The only thing we know about __builtin_signbit is that is 0 or non-zero. The
exact value is unspecified for the non-zero case. So we can only optimize the
!=/== 0 cases.

[Bug c/109826] Incompatible pointer types in ?: not covered by -Wincompatible-pointer-types

2023-05-13 Thread egallager at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109826

Eric Gallager  changed:

   What|Removed |Added

 CC||egallager at gcc dot gnu.org
 Blocks||44209

--- Comment #3 from Eric Gallager  ---
(In reply to Andrew Pinski from comment #2)
> The warning is not even controlled by an option either so only -Werror turns
> it into an error.

Thus, this fits under bug 44209


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=44209
[Bug 44209] [meta-bug] Some warnings are not linked to diagnostics options

[Bug c/109836] -Wpointer-sign should be enabled by default

2023-05-13 Thread egallager at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109836

Eric Gallager  changed:

   What|Removed |Added

 CC||egallager at gcc dot gnu.org

--- Comment #4 from Eric Gallager  ---
How about:

diff --git a/gcc/c-family/c.opt b/gcc/c-family/c.opt
index 0d0ad0a6374..f046d91d03b 100644
--- a/gcc/c-family/c.opt
+++ b/gcc/c-family/c.opt
@@ -1178,7 +1178,7 @@ C ObjC C++ ObjC++ Var(warn_pointer_arith) Warning
LangEnabledBy(C ObjC C++ ObjC+
 Warn about function pointer arithmetic.

 Wpointer-sign
-C ObjC Var(warn_pointer_sign) Warning LangEnabledBy(C ObjC,Wall || Wpedantic)
+C ObjC Var(warn_pointer_sign) Warning LangEnabledBy(C ObjC,Wall || Wpedantic
|| Wextra)
 Warn when a pointer differs in signedness in an assignment.

 Wpointer-compare

[Bug c/109835] -Wincompatible-function-pointer-types as a subset of -Wincompatible-pointer-types?

2023-05-13 Thread egallager at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109835

Eric Gallager  changed:

   What|Removed |Added

 CC||egallager at gcc dot gnu.org

--- Comment #3 from Eric Gallager  ---
I thought that there was already a separate bug for this, but it turns out that
I was thinking of bug 87379, which is for something different...

[Bug tree-optimization/108684] [12 Regression] ICE: verify_ssa failed

2023-05-13 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108684

Andrew Pinski  changed:

   What|Removed |Added

 CC||141242068 at smail dot 
nju.edu.cn

--- Comment #17 from Andrew Pinski  ---
*** Bug 109842 has been marked as a duplicate of this bug. ***

[Bug tree-optimization/109842] GCC-12 hangs on simple piece of inline assembly code

2023-05-13 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109842

Andrew Pinski  changed:

   What|Removed |Added

 Resolution|FIXED   |DUPLICATE

--- Comment #3 from Andrew Pinski  ---
Yes it is a dup. In this case, the "Check all ssa names " part of the patch
fixes it.

*** This bug has been marked as a duplicate of bug 108684 ***

[PATCH v3] Machine_Mode: Extend machine_mode from 8 to 16 bits

2023-05-13 Thread Pan Li via Gcc-patches
From: Pan Li 

We are running out of the machine_mode(8 bits) in RISC-V backend. Thus
we would like to extend the machine_mode bit size from 8 to 16 bits.
However, it is sensitive to extend the memory size in common structure
like tree or rtx. This patch would like to extend the machine_mode bits
to 16 bits by shrinking, like:

* Swap the bit size of code and machine code in rtx_def.
* Adjust the machine_mode location and spare in tree.

The memory impact of this patch for correlated structure looks like below:

+---+--+-+--+
| struct/bytes  | upstream | patched | diff |
+---+--+-+--+
| rtx_obj_reference |8 |  12 |   +4 |
| ext_modified  |2 |   4 |   +2 |
| ira_allocno   |  192 | 184 |   -8 |
| qty_table_elem|   40 |  40 |0 |
| reg_stat_type |   64 |  64 |0 |
| rtx_def   |   40 |  40 |0 |
| table_elt |   80 |  80 |0 |
| tree_decl_common  |  112 | 112 |0 |
| tree_type_common  |  128 | 128 |0 |
+---+--+-+--+

The tree and rtx related struct has no memory changes after this patch,
and the machine_mode changes to 16 bits already.

Signed-off-by: Pan Li 
Co-authored-by: Ju-Zhe Zhong 
Co-authored-by: Kito Cheng 
Co-Authored-By: Richard Biener 
Co-Authored-By: Richard Sandiford 

gcc/ChangeLog:

* combine.cc (struct reg_stat_type): Extend machine_mode to 16 bits.
* cse.cc (struct qty_table_elem): Extend machine_mode to 16 bits
(struct table_elt): Extend machine_mode to 16 bits.
(struct set): Ditto.
* genmodes.cc (emit_mode_wider): Extend type from char to short.
(emit_mode_complex): Ditto.
(emit_mode_inner): Ditto.
(emit_class_narrowest_mode): Ditto.
* genopinit.cc (main): Extend the machine_mode limit.
* ira-int.h (struct ira_allocno): Extend machine_mode to 16 bits and
re-ordered the struct fields for padding.
* machmode.h (MACHINE_MODE_BITSIZE): New macro.
(GET_MODE_2XWIDER_MODE): Extend type from char to short.
(get_mode_alignment): Extend type from char to short.
* ree.cc (struct ext_modified): Extend machine_mode to 16 bits and
removed the ATTRIBUTE_PACKED.
* rtl-ssa/accesses.h: Extend machine_mode to 16 bits.
* rtl.h (RTX_CODE_BITSIZE): New macro.
(struct rtx_def): Swap both the bit size and location between the
rtx_code and the machine_mode.
(subreg_shape::unique_id): Extend the machine_mode limit.
* rtlanal.h: Extend machine_mode to 16 bits.
* tree-core.h (struct tree_type_common): Extend machine_mode to 16
bits and re-ordered the struct fields for padding.
(struct tree_decl_common): Extend machine_mode to 16 bits.
---
 gcc/combine.cc |  4 +--
 gcc/cse.cc | 16 
 gcc/genmodes.cc| 16 ++--
 gcc/genopinit.cc   |  3 ++-
 gcc/ira-int.h  | 56 +-
 gcc/machmode.h | 27 +++-
 gcc/ree.cc |  4 +--
 gcc/rtl-ssa/accesses.h |  2 +-
 gcc/rtl.h  | 12 +
 gcc/rtlanal.h  |  2 +-
 gcc/tree-core.h|  9 ---
 11 files changed, 82 insertions(+), 69 deletions(-)

diff --git a/gcc/combine.cc b/gcc/combine.cc
index 5aa0ec5c45a..a23caeed96f 100644
--- a/gcc/combine.cc
+++ b/gcc/combine.cc
@@ -200,7 +200,7 @@ struct reg_stat_type {
 
   unsigned HOST_WIDE_INT   last_set_nonzero_bits;
   char last_set_sign_bit_copies;
-  ENUM_BITFIELD(machine_mode)  last_set_mode : 8;
+  ENUM_BITFIELD(machine_mode)  last_set_mode : MACHINE_MODE_BITSIZE;
 
   /* Set nonzero if references to register n in expressions should not be
  used.  last_set_invalid is set nonzero when this register is being
@@ -235,7 +235,7 @@ struct reg_stat_type {
  truncation if we know that value already contains a truncated
  value.  */
 
-  ENUM_BITFIELD(machine_mode)  truncated_to_mode : 8;
+  ENUM_BITFIELD(machine_mode)  truncated_to_mode : MACHINE_MODE_BITSIZE;
 };
 
 
diff --git a/gcc/cse.cc b/gcc/cse.cc
index b10c9b0c94d..86403b95938 100644
--- a/gcc/cse.cc
+++ b/gcc/cse.cc
@@ -248,10 +248,8 @@ struct qty_table_elem
   rtx comparison_const;
   int comparison_qty;
   unsigned int first_reg, last_reg;
-  /* The sizes of these fields should match the sizes of the
- code and mode fields of struct rtx_def (see rtl.h).  */
-  ENUM_BITFIELD(rtx_code) comparison_code : 16;
-  ENUM_BITFIELD(machine_mode) mode : 8;
+  ENUM_BITFIELD(machine_mode) mode : MACHINE_MODE_BITSIZE;
+  ENUM_BITFIELD(rtx_code) comparison_code : RTX_CODE_BITSIZE;
 };
 
 /* The table of all qtys, indexed by qty number.  */
@@ -404,9 +402,7 @@ struct table_elt
   struct table_elt *related_value;
   int cost;
   int regcost;
-  /* The size of this field 

[Bug libstdc++/109818] std::trunc() requires a hack after building DJGPP

2023-05-13 Thread janezz55 at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109818

--- Comment #26 from Janez Zemva  ---
I am a c++ user, so I don't like using c header files if at all possible. I am
pleased with how things are: I now compile/link a replacement libm and replace
the sloppy djgpp header files, but I haven't tested this arrangement yet. Maybe
it works.

RE: [PATCH] Machine_Mode: Extend machine_mode from 8 to 16 bits

2023-05-13 Thread Li, Pan2 via Gcc-patches
Oops, looks missed this part when I search all machine_mode by word. Thanks 
kito for catching this.

It seems there is no easy way to remind the developer to change (for example 16 
to 32 bits) the below part in future, how about add some comments to 
MACHINE_MODE_BITSIZE for this?

Pan

-Original Message-
From: Kito Cheng  
Sent: Saturday, May 13, 2023 4:45 PM
To: Bernhard Reutner-Fischer 
Cc: Richard Biener ; Richard Biener via Gcc-patches 
; Li, Pan2 ; juzhe.zh...@rivai.ai; 
Wang, Yanzhang ; jeffreya...@gmail.com; 
richard.sandif...@arm.com
Subject: Re: [PATCH] Machine_Mode: Extend machine_mode from 8 to 16 bits

Hi Pan:

Tried this patch and I ran into some issues, some variables are using unsigned 
char to hold machine mode and will have problems when the number of modes is 
larger than 255...

And here is the fix:


diff --git a/gcc/genmodes.cc b/gcc/genmodes.cc index 715787b8f483..55ac2adb5596 
100644
--- a/gcc/genmodes.cc
+++ b/gcc/genmodes.cc
@@ -1141,10 +1141,10 @@ inline __attribute__((__always_inline__))\n\
#else\n\
extern __inline__ __attribute__((__always_inline__, __gnu_inline__))\n\ 
#endif\n\ -unsigned char\n\
+unsigned short\n\
mode_inner_inline (machine_mode mode)\n\ {\n\
-  extern const unsigned char mode_inner[NUM_MACHINE_MODES];\n\
+  extern const unsigned short mode_inner[NUM_MACHINE_MODES];\n\
  gcc_assert (mode >= 0 && mode < NUM_MACHINE_MODES);\n\
  switch (mode)\n\
{");
@@ -1529,7 +1529,7 @@ emit_mode_wider (void)
  int c;
  struct mode_data *m;

-  print_decl ("unsigned char", "mode_next", "NUM_MACHINE_MODES");
+  print_decl ("unsigned short", "mode_next", "NUM_MACHINE_MODES");

  for_all_modes (c, m)
tagged_printf ("E_%smode",
@@ -1537,7 +1537,7 @@ emit_mode_wider (void)
  m->name);

  print_closer ();
-  print_decl ("unsigned char", "mode_wider", "NUM_MACHINE_MODES");
+  print_decl ("unsigned short", "mode_wider", "NUM_MACHINE_MODES");

  for_all_modes (c, m)
{
@@ -1568,7 +1568,7 @@ emit_mode_wider (void)
}

  print_closer ();
-  print_decl ("unsigned char", "mode_2xwider", "NUM_MACHINE_MODES");
+  print_decl ("unsigned short", "mode_2xwider", "NUM_MACHINE_MODES");

  for_all_modes (c, m)
{
@@ -1625,7 +1625,7 @@ emit_mode_complex (void)
  int c;
  struct mode_data *m;

-  print_decl ("unsigned char", "mode_complex", "NUM_MACHINE_MODES");
+  print_decl ("unsigned short", "mode_complex", "NUM_MACHINE_MODES");

  for_all_modes (c, m)
tagged_printf ("E_%smode",
@@ -1665,7 +1665,7 @@ emit_mode_inner (void)
  int c;
  struct mode_data *m;

-  print_decl ("unsigned char", "mode_inner", "NUM_MACHINE_MODES");
+  print_decl ("unsigned short", "mode_inner", "NUM_MACHINE_MODES");

  for_all_modes (c, m)
tagged_printf ("E_%smode",
@@ -1738,7 +1738,7 @@ emit_class_narrowest_mode (void) {
  int c;

-  print_decl ("unsigned char", "class_narrowest_mode", "MAX_MODE_CLASS");
+  print_decl ("unsigned short", "class_narrowest_mode", 
+ "MAX_MODE_CLASS");

  for (c = 0; c < MAX_MODE_CLASS; c++)
{
diff --git a/gcc/machmode.h b/gcc/machmode.h index f1865c1ef425..a168d6f0da2e 
100644
--- a/gcc/machmode.h
+++ b/gcc/machmode.h
@@ -24,13 +24,13 @@ typedef opt_mode opt_machine_mode;

extern CONST_MODE_SIZE poly_uint16_pod mode_size[NUM_MACHINE_MODES]; extern 
CONST_MODE_PRECISION poly_uint16_pod mode_precision[NUM_MACHINE_MODES];
-extern const unsigned char mode_inner[NUM_MACHINE_MODES];
+extern const unsigned short mode_inner[NUM_MACHINE_MODES];
extern CONST_MODE_NUNITS poly_uint16_pod mode_nunits[NUM_MACHINE_MODES]; extern 
CONST_MODE_UNIT_SIZE unsigned char mode_unit_size[NUM_MACHINE_MODES];
extern const unsigned short mode_unit_precision[NUM_MACHINE_MODES];
-extern const unsigned char mode_next[NUM_MACHINE_MODES]; -extern const 
unsigned char mode_wider[NUM_MACHINE_MODES]; -extern const unsigned char 
mode_2xwider[NUM_MACHINE_MODES];
+extern const unsigned short mode_next[NUM_MACHINE_MODES]; extern const 
+unsigned short mode_wider[NUM_MACHINE_MODES]; extern const unsigned 
+short mode_2xwider[NUM_MACHINE_MODES];

template
struct mode_traits
@@ -797,7 +797,7 @@ GET_MODE_2XWIDER_MODE (const T ) }

/* Get the complex mode from the component mode.  */ -extern const unsigned 
char mode_complex[NUM_MACHINE_MODES];
+extern const unsigned short mode_complex[NUM_MACHINE_MODES];
#define GET_MODE_COMPLEX_MODE(MODE) ((machine_mode) mode_complex[MODE])

/* Represents a machine mode that must have a fixed size.  The main @@ -946,7 
+946,7 @@ extern unsigned get_mode_alignment (machine_mode);

/* For each class, get the narrowest mode in that class.  */

-extern const unsigned char class_narrowest_mode[MAX_MODE_CLASS];
+extern const unsigned short class_narrowest_mode[MAX_MODE_CLASS];
#define GET_CLASS_NARROWEST_MODE(CLASS) \
  ((machine_mode) class_narrowest_mode[CLASS])

--
2.39.2


[Bug tree-optimization/94911] Failure to optimize comparisons of VLA sizes

2023-05-13 Thread gabravier at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94911

--- Comment #5 from Gabriel Ravier  ---
Also, as an extra note, w.r.t.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94911#c3, I've just noticed that I
had indeed made a separate bug report at https://gcc.gnu.org/PR94912 (which
ended up being closed as a duplicate of https://gcc.gnu.org/PR68531) - just
wanted to clarify that so nobody ends up filing more duplicates like I almost
just did

[Bug ipa/109817] internal error in ICF pass on Ada interfaces

2023-05-13 Thread ebotcazou at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109817

Eric Botcazou  changed:

   What|Removed |Added

 Ever confirmed|0   |1
 Status|UNCONFIRMED |NEW
Version|unknown |14.0
  Component|ada |ipa
 CC||ebotcazou at gcc dot gnu.org,
   ||marxin at gcc dot gnu.org
   Last reconfirmed||2023-05-13
Summary|-O2 and |internal error in ICF pass
   |./gnat.dg/sync_iface_call_p |on Ada interfaces
   |kg2.adb don't mix   |

--- Comment #1 from Eric Botcazou  ---
Yes, the ICF pass is not run at -O2 and -fno-ipa-icf is a workaround.

[PATCH] RISC-V: Support TARGET_VECTORIZE_PREFERRED_VECTOR_ALIGNMENT to optimize codegen of RVV auto-vectorization

2023-05-13 Thread juzhe . zhong
From: Juzhe-Zhong 

This patch support vector alignement for RVV auto-vectorization.

Consider this following case:
void __attribute__((noinline, noclone))
f (int * __restrict dst, int * __restrict op1, int * __restrict op2, int count)
{
  for (int i = 0; i < count; ++i)
dst[i] = op1[i] + op2[i];
}

Before this patch:
ble a3,zero,.L1
srlia4,a1,2
negwa4,a4
andia5,a4,3
sext.w  a3,a3
beq a5,zero,.L3
lw  a7,0(a1)
lw  a6,0(a2)
andia4,a4,2
addwa6,a6,a7
sw  a6,0(a0)
beq a4,zero,.L3
lw  a7,4(a1)
lw  a4,4(a2)
li  a6,3
addwa4,a4,a7
sw  a4,4(a0)
bne a5,a6,.L3
lw  a6,8(a2)
lw  a4,8(a1)
addwa4,a4,a6
sw  a4,8(a0)
.L3:
subwa3,a3,a5
sllia4,a3,32
csrra6,vlenb
srlia4,a4,32
srlia6,a6,2
sllia3,a5,2
mv  a5,a4
bgtua4,a6,.L17
.L5:
csrra6,vlenb
add a1,a1,a3
add a2,a2,a3
add a0,a0,a3
srlia7,a6,2
li  a3,0
.L8:
vsetvli zero,a5,e32,m1,ta,ma
vle32.v v1,0(a1)
vle32.v v2,0(a2)
vsetvli t1,zero,e32,m1,ta,ma
add a3,a3,a7
vadd.vv v1,v1,v2
vsetvli zero,a5,e32,m1,ta,ma
vse32.v v1,0(a0)
mv  a5,a4
bleua4,a3,.L6
mv  a5,a3
.L6:
sub a5,a4,a5
bleua5,a7,.L7
mv  a5,a7
.L7:
add a1,a1,a6
add a2,a2,a6
add a0,a0,a6
bne a5,zero,.L8
.L1:
ret
.L17:
mv  a5,a6
j   .L5

After this patch:
f:
ble a3,zero,.L1
csrra4,vlenb
srlia4,a4,2
mv  a5,a3
bgtua3,a4,.L9
.L3:
csrra6,vlenb
li  a4,0
srlia7,a6,2
.L6:
vsetvli zero,a5,e32,m1,ta,ma
vle32.v v2,0(a1)
vle32.v v1,0(a2)
vsetvli t1,zero,e32,m1,ta,ma
add a4,a4,a7
vadd.vv v1,v1,v2
vsetvli zero,a5,e32,m1,ta,ma
vse32.v v1,0(a0)
mv  a5,a3
bleua3,a4,.L4
mv  a5,a4
.L4:
sub a5,a3,a5
bleua5,a7,.L5
mv  a5,a7
.L5:
add a0,a0,a6
add a2,a2,a6
add a1,a1,a6
bne a5,zero,.L6
.L1:
ret
.L9:
mv  a5,a4
j   .L3

gcc/ChangeLog:

* config/riscv/riscv.cc (riscv_vectorize_preferred_vector_alignment): 
New function.
(TARGET_VECTORIZE_PREFERRED_VECTOR_ALIGNMENT): New target hook.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/binop/shift-rv32gcv.c: Adapt testcase.
* gcc.target/riscv/rvv/autovec/align-1.c: New test.

---
 gcc/config/riscv/riscv.cc | 22 +++
 .../gcc.target/riscv/rvv/autovec/align-1.c| 12 ++
 .../riscv/rvv/autovec/binop/shift-rv32gcv.c   | 10 +
 3 files changed, 40 insertions(+), 4 deletions(-)
 create mode 100644 gcc/testsuite/gcc.target/riscv/rvv/autovec/align-1.c

diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc
index de578b5b899..a5776a550b2 100644
--- a/gcc/config/riscv/riscv.cc
+++ b/gcc/config/riscv/riscv.cc
@@ -7499,6 +7499,24 @@ riscv_preferred_simd_mode (scalar_mode mode)
   return word_mode;
 }
 
+/* Implement target hook TARGET_VECTORIZE_PREFERRED_VECTOR_ALIGNMENT.  */
+
+static poly_uint64
+riscv_vectorize_preferred_vector_alignment (const_tree type)
+{
+  if (riscv_v_ext_vector_mode_p (TYPE_MODE (type)))
+{
+  /* If the length of the vector is a fixed power of 2, try to align
+to that length, otherwise don't try to align at all.  */
+  HOST_WIDE_INT result;
+  if (!GET_MODE_BITSIZE (TYPE_MODE (type)).is_constant ()
+ || !pow2p_hwi (result))
+   result = TYPE_ALIGN (TREE_TYPE (type));
+  return result;
+}
+  return TYPE_ALIGN (type);
+}
+
 /* Initialize the GCC target structure.  */
 #undef TARGET_ASM_ALIGNED_HI_OP
 #define TARGET_ASM_ALIGNED_HI_OP "\t.half\t"
@@ -7771,6 +7789,10 @@ riscv_preferred_simd_mode (scalar_mode mode)
 #undef TARGET_VECTORIZE_PREFERRED_SIMD_MODE
 #define TARGET_VECTORIZE_PREFERRED_SIMD_MODE riscv_preferred_simd_mode
 
+#undef TARGET_VECTORIZE_PREFERRED_VECTOR_ALIGNMENT
+#define TARGET_VECTORIZE_PREFERRED_VECTOR_ALIGNMENT \
+  riscv_vectorize_preferred_vector_alignment
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 #include "gt-riscv.h"
diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/align-1.c 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/align-1.c
new file mode 100644
index 000..14201e1f7e0
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/align-1.c
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv32gcv -mabi=ilp32d -O3 --param 

Re: [PATCH] tree: Fix up save_expr [PR52339]

2023-05-13 Thread Eric Botcazou via Gcc-patches
> I think we really need Eric (as one who e.g. introduced the
> DECL_INVARIANT_P apparently for this kind of stuff) to have a look at that
> on the Ada side.

I have been investigating this for a few days and it's no small change for Ada 
and probably for other languages with dynamic types.  SAVE_EXPRs are delicate 
to handle because 1) they are TREE_SIDE_EFFECTS (it's explained in save_expr) 
so out of TREE_READONLY && !TREE_SIDE_EFFECTS trees, you now get side effects 
which then propagate to all parent nodes 2) their placement is problematic in 
conditional expressions, for example if you replace

  cond > 0 ? A : A + 1

with

  cond > 0 ? SAVE_EXPR (A) : SAVE_EXPR (A) + 1

then gimplification will, say, create the temporary and initialize it in the 
first arm so, if at runtime you take the second arm, you'll read the temporary 
uninitialized.  That's caught for scalar values by the SSA form (if your patch 
is applied to a GCC 12 tree, you'll get ICEs in the ACATS testsuite because of 
this through finalize_type_size -> variable_size -> save_expr, it is probably 
mitigated/addressed in GCC 14 by 68e0063397ba820e71adc220b2da0581dce29ffa).
That's also why making gnat_invariant_expr return (some of) them does not look 
really safe.

In addition to this, in Ada we have bounds of unconstrained arrays which are 
both read-only and stored indirectly, i.e. you have an INDIRECT_REF in the 
tree (it is marked TREE_THIS_NOTRAP because the bounds are always present), 
and which obviously play a crucial role in loops running over the arrays.
This issue is responsible for the regressions in the gnat.dg testsuite.

I think that we can reasonably deal with the second issue in the Ada front-end 
because we know the semantics of the bounds of unconstrained arrays, and I'm 
testing a patch to that effect, but the first issue might be annoying too.

-- 
Eric Botcazou




[Bug target/109807] [14 Regression] sse2-mmx-pmaddwd.c met ICE after commit r14-666-g608e7f3ab47 with march=cascadelake

2023-05-13 Thread ubizjak at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109807

--- Comment #11 from Uroš Bizjak  ---
(In reply to David Binderman from comment #10)
> (In reply to Uroš Bizjak from comment #8)
> > Fixed.
> 
> I don't think so. The code I gave seems still to crash the compiler:

Yes, the cost function is ICEing on unhandled modes (that is *not* a good
approach). Please look at the PR109825 how it will be solved.

[Bug target/109807] [14 Regression] sse2-mmx-pmaddwd.c met ICE after commit r14-666-g608e7f3ab47 with march=cascadelake

2023-05-13 Thread dcb314 at hotmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109807

--- Comment #10 from David Binderman  ---
(In reply to Uroš Bizjak from comment #8)
> Fixed.

I don't think so. The code I gave seems still to crash the compiler:

$ ~/gcc/results/bin/gcc -v
Using built-in specs.
COLLECT_GCC=/home/dcb38/gcc/results/bin/gcc
COLLECT_LTO_WRAPPER=/home/dcb38/gcc/results.20230513.asan.ubsan/libexec/gcc/x86_64-pc-linux-gnu/14.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../trunk.year/configure
--prefix=/home/dcb38/gcc/results.20230513.asan.ubsan --disable-multilib
--disable-bootstrap --with-build-config=bootstrap-asan
--with-build-config=bootstrap-ubsan --with-pkgversion=1d339ce8d002920f
--enable-checking=df,extra,fold,rtl,yes --enable-languages=c,c++,fortran
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 14.0.0 20230513 (experimental) (1d339ce8d002920f)


$ ~/gcc/results/bin/gcc -c -O2 -march=znver1 bug919.c
during GIMPLE pass: slp
edid-parse.c: In function ‘decode_edid’:
edid-parse.c:521:14: internal compiler error: in ix86_widen_mult_cost, at
config
/i386/i386.cc:20444
0x11f3ab1 ix86_widen_mult_cost(processor_costs const*, machine_mode, bool)
../../trunk.year/gcc/config/i386/i386.cc:20444

I thought at first I hadn't picked up Uros's change, but:

$ git log | fgrep V4HI
fgrep: warning: fgrep is obsolescent; using grep -F
i386: Handle V4HI and V2SImode in ix86_widen_mult_cost [PR109807]
a widening mul operation to V4HI or V2SImode.
Handle V4HImode and V2SImode.
The operation ADDHN on V4SI, for example, is represented as (truncate:V4HI
((src1:V4SI + src2:V4SI) >> 16))
and RADDHN as (truncate:V4HI ((src1:V4SI + src2:V4SI + (1 << 15)) >> 16)).
$

[Bug tree-optimization/109842] GCC-12 hangs on simple piece of inline assembly code

2023-05-13 Thread xry111 at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109842

Xi Ruoyao  changed:

   What|Removed |Added

 Resolution|--- |FIXED
  Component|middle-end  |tree-optimization
   Target Milestone|--- |12.3
   See Also||https://gcc.gnu.org/bugzill
   ||a/show_bug.cgi?id=108684
 CC||pinskia at gcc dot gnu.org
 Status|UNCONFIRMED |RESOLVED

--- Comment #2 from Xi Ruoyao  ---
It's fixed by r12-9239.  I'm not sure if it's a duplicate of PR108684 though,
so mark it FIXED.  If this is a duplicate please modify the field.

[Bug libstdc++/109818] std::trunc() requires a hack after building DJGPP

2023-05-13 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109818

--- Comment #25 from Jonathan Wakely  ---
I think the simplest solution for this bug is just use  and call trunc
instead of trying to use std::trunc. If you use the  functions in the
global namespace then you get exactly the set that is supported by djgpp, not
the incomplete set that gets imported into namespace std. It's not ideal, but
there's only so much we can do when the underlying  is incomplete.

[PATCH V2] Provide -fcf-protection=branch,return.

2023-05-13 Thread liuhongt via Gcc-patches
> I think this could be simplified if you use either EnumSet or
> EnumBitSet instead in common.opt for `-fcf-protection=`.

Use EnumSet instead of EnumBitSet since CF_FULL is not power of 2.
It is a bit tricky for sets classification, cf_branch and cf_return
should be in different sets, but they both "conflicts" cf_full,
cf_none. And current EnumSet don't handle this well.

So in the current implementation, only cf_full,cf_none are exclusive
to each other, but they can be combined with any cf_branch, cf_return,
cf_check. It's not perfect, but still an improvement than original
one.

gcc/ChangeLog:

* common.opt: (fcf-protection=): Add EnumSet attribute to
support combination of params.

gcc/testsuite/ChangeLog:

* c-c++-common/fcf-protection-10.c: New test.
* c-c++-common/fcf-protection-11.c: New test.
* c-c++-common/fcf-protection-12.c: New test.
* c-c++-common/fcf-protection-8.c: New test.
* c-c++-common/fcf-protection-9.c: New test.
* gcc.target/i386/pr89701-1.c: New test.
* gcc.target/i386/pr89701-2.c: New test.
* gcc.target/i386/pr89701-3.c: New test.
---
 gcc/common.opt | 12 ++--
 gcc/testsuite/c-c++-common/fcf-protection-10.c |  2 ++
 gcc/testsuite/c-c++-common/fcf-protection-11.c |  2 ++
 gcc/testsuite/c-c++-common/fcf-protection-12.c |  2 ++
 gcc/testsuite/c-c++-common/fcf-protection-8.c  |  2 ++
 gcc/testsuite/c-c++-common/fcf-protection-9.c  |  2 ++
 gcc/testsuite/gcc.target/i386/pr89701-1.c  |  4 
 gcc/testsuite/gcc.target/i386/pr89701-2.c  |  4 
 gcc/testsuite/gcc.target/i386/pr89701-3.c  |  4 
 9 files changed, 28 insertions(+), 6 deletions(-)
 create mode 100644 gcc/testsuite/c-c++-common/fcf-protection-10.c
 create mode 100644 gcc/testsuite/c-c++-common/fcf-protection-11.c
 create mode 100644 gcc/testsuite/c-c++-common/fcf-protection-12.c
 create mode 100644 gcc/testsuite/c-c++-common/fcf-protection-8.c
 create mode 100644 gcc/testsuite/c-c++-common/fcf-protection-9.c
 create mode 100644 gcc/testsuite/gcc.target/i386/pr89701-1.c
 create mode 100644 gcc/testsuite/gcc.target/i386/pr89701-2.c
 create mode 100644 gcc/testsuite/gcc.target/i386/pr89701-3.c

diff --git a/gcc/common.opt b/gcc/common.opt
index a28ca13385a..02f2472959a 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -1886,7 +1886,7 @@ fcf-protection
 Common RejectNegative Alias(fcf-protection=,full)
 
 fcf-protection=
-Common Joined RejectNegative Enum(cf_protection_level) Var(flag_cf_protection) 
Init(CF_NONE)
+Common Joined RejectNegative Enum(cf_protection_level) EnumSet 
Var(flag_cf_protection) Init(CF_NONE)
 -fcf-protection=[full|branch|return|none|check]Instrument functions 
with checks to verify jump/call/return control-flow transfer
 instructions have valid targets.
 
@@ -1894,19 +1894,19 @@ Enum
 Name(cf_protection_level) Type(enum cf_protection_level) UnknownError(unknown 
Control-Flow Protection Level %qs)
 
 EnumValue
-Enum(cf_protection_level) String(full) Value(CF_FULL)
+Enum(cf_protection_level) String(full) Value(CF_FULL) Set(1)
 
 EnumValue
-Enum(cf_protection_level) String(branch) Value(CF_BRANCH)
+Enum(cf_protection_level) String(branch) Value(CF_BRANCH) Set(2)
 
 EnumValue
-Enum(cf_protection_level) String(return) Value(CF_RETURN)
+Enum(cf_protection_level) String(return) Value(CF_RETURN) Set(3)
 
 EnumValue
-Enum(cf_protection_level) String(check) Value(CF_CHECK)
+Enum(cf_protection_level) String(check) Value(CF_CHECK) Set(4)
 
 EnumValue
-Enum(cf_protection_level) String(none) Value(CF_NONE)
+Enum(cf_protection_level) String(none) Value(CF_NONE) Set(1)
 
 finstrument-functions
 Common Var(flag_instrument_function_entry_exit,1)
diff --git a/gcc/testsuite/c-c++-common/fcf-protection-10.c 
b/gcc/testsuite/c-c++-common/fcf-protection-10.c
new file mode 100644
index 000..b271d134e52
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/fcf-protection-10.c
@@ -0,0 +1,2 @@
+/* { dg-do compile { target { "i?86-*-* x86_64-*-*" } } } */
+/* { dg-options "-fcf-protection=branch,check" } */
diff --git a/gcc/testsuite/c-c++-common/fcf-protection-11.c 
b/gcc/testsuite/c-c++-common/fcf-protection-11.c
new file mode 100644
index 000..2e566350ccd
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/fcf-protection-11.c
@@ -0,0 +1,2 @@
+/* { dg-do compile { target { "i?86-*-* x86_64-*-*" } } } */
+/* { dg-options "-fcf-protection=branch,return" } */
diff --git a/gcc/testsuite/c-c++-common/fcf-protection-12.c 
b/gcc/testsuite/c-c++-common/fcf-protection-12.c
new file mode 100644
index 000..b39c2f8e25d
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/fcf-protection-12.c
@@ -0,0 +1,2 @@
+/* { dg-do compile { target { "i?86-*-* x86_64-*-*" } } } */
+/* { dg-options "-fcf-protection=return,branch" } */
diff --git a/gcc/testsuite/c-c++-common/fcf-protection-8.c 
b/gcc/testsuite/c-c++-common/fcf-protection-8.c
new file mode 100644
index 000..3b97095a92c
--- /dev/null

[Bug middle-end/109842] GCC-12 hangs on simple piece of inline assembly code

2023-05-13 Thread xry111 at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109842

Xi Ruoyao  changed:

   What|Removed |Added

  Known to fail||12.1.0, 12.2.0
  Known to work||11.1.0, 12.3.0, 13.1.0
 CC||xry111 at gcc dot gnu.org

--- Comment #1 from Xi Ruoyao  ---
Looks like a duplicate of some bug fixed in 12.3.

Re: [Patch] LTO: Fix writing of toplevel asm with offloading [PR109816]

2023-05-13 Thread Thomas Schwinge
Hi!

On 2023-05-12T14:46:21+0200, Tobias Burnus  wrote:
> Long standing issue but as top-level 'asm' statement were rare, it did not 
> show up.

Thanks for tracking this down, and fixing it!  Presumably latent
"forever" (here: since code offloading support was added, approximately
one decade ago).

> However, the fix for PR108969 in commit r14-321-g9a41d2cdbcd added code
>
> +#elif defined(_GLIBCXX_SYMVER_GNU)
> +  __extension__ __asm (".globl _ZSt21ios_base_library_initv");
> q
> libstdc++-v3/include/std/iostream. This was then duly written by the 
> offloading-device
> lto1 for digestion by the device-target assembler. While the llvm-mc linker 
> user by
> GCN did accept .globl, nvptx's ptxas did choke on it.
>
> Additionally, as the assembly was already written for offloading, the output 
> was
> lost on the host when using LTO for not only for offload but for real (i.e. 
> with -flto).

> Has someone an idea how to check whether the offloading-code assembler does 
> not
> contain the _ZSt21ios_base_library_initv while the host-side (before or after 
> LTO)
> should contain it, but only with _GLIBCXX_SYMVER_GNU?
> Otherwise, the testcase tests only and at least whether it breaks with nvptx
> as ptxas does not like the symbol.

We can construct test cases with their own top-level 'asm', outside of
the libstdc++ context?  I'll try to come up with something.


> The installed-build regtesting of "make check-target-libgomp" seems to be 
> currently broken
> as it does run all checking code (check_effective_target...) but does not 
> seem to find
> any actual testcase to be run, probably a side effect of the recent testsuite 
> changes.

FUD.  ;-O

We've since determined that Tobias' testing problem was due to
'//net/[...]' (double-slash) paths usage (with '/net' served by
'/etc/auto.master:/net -hosts'), which apparently confused DejaGnu/TCL
'find' (as used in 'libgomp/testsuite/libgomp.*/*.exp').

Per
:

| By the way, all changes (individually) tested in a number of different
| configurations: '--enable-languages=[...]', native vs. cross, build-tree
| vs. installed testing, etc.


Grüße
 Thomas
-
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


[Bug middle-end/109842] New: GCC-12 hangs on simple piece of inline assembly code

2023-05-13 Thread 141242068 at smail dot nju.edu.cn via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109842

Bug ID: 109842
   Summary: GCC-12 hangs on simple piece of inline assembly code
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: middle-end
  Assignee: unassigned at gcc dot gnu.org
  Reporter: 141242068 at smail dot nju.edu.cn
  Target Milestone: ---

The bug-triggering testcase:

```
$ cat c.c
static int t;

int f_tt;
int f(void) {
  int tt1;
  asm("" : "=r"(f_tt), "=r"(tt1));
  t = tt1;
  return f_tt;
}

```

When compiled with `gcc-12 -O2`, gcc hangs
```
-> tmp $ gcc-12 -O2 c.c
^C
```

My gcc version:
```
-> tmp $ gcc-12 -v
Using built-in specs.
COLLECT_GCC=gcc-12
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/12/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
12.1.0-2ubuntu1~22.04' --with-bugurl=file:///usr/share/doc/gcc-12/README.Bugs
--enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2 --prefix=/usr
--with-gcc-major-version-only --program-suffix=-12
--program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new
--enable-gnu-unique-object --disable-vtable-verify --enable-plugin
--enable-default-pie --with-system-zlib --enable-libphobos-checking=release
--with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch
--disable-werror --enable-cet --with-arch-32=i686 --with-abi=m64
--with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic
--enable-offload-targets=nvptx-none=/build/gcc-12-sZcx2y/gcc-12-12.1.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-12-sZcx2y/gcc-12-12.1.0/debian/tmp-gcn/usr
--enable-offload-defaulted --without-cuda-driver --enable-checking=release
--build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.1.0 (Ubuntu 12.1.0-2ubuntu1~22.04)

```

Re: [aarch64] Use dup and zip1 for interleaving elements in initializing vector

2023-05-13 Thread Prathamesh Kulkarni via Gcc-patches
On Fri, 12 May 2023 at 00:37, Richard Sandiford
 wrote:
>
> Prathamesh Kulkarni  writes:
> > diff --git a/gcc/testsuite/gcc.target/aarch64/vec-init-18.c 
> > b/gcc/testsuite/gcc.target/aarch64/vec-init-18.c
> > new file mode 100644
> > index 000..598a51f17c6
> > --- /dev/null
> > +++ b/gcc/testsuite/gcc.target/aarch64/vec-init-18.c
> > @@ -0,0 +1,20 @@
> > +/* { dg-do compile } */
> > +/* { dg-options "-O3" } */
> > +
> > +#include 
> > +
> > +int16x8_t foo(int16_t x, int y)
> > +{
> > +  int16x8_t v = (int16x8_t) {x, y, x, y, x, y, x, y};
> > +  return v;
> > +}
> > +
> > +int16x8_t foo2(int16_t x)
> > +{
> > +  int16x8_t v = (int16x8_t) {x, 1, x, 1, x, 1, x, 1};
> > +  return v;
> > +}
> > +
> > +/* { dg-final { scan-assembler-times {\tdup\tv[0-9]+\.4h, w[0-9]+} 3 } } */
> > +/* { dg-final { scan-assembler {\tmovi\tv[0-9]+\.4h, 0x1} } } */
> > +/* { dg-final { scan-assembler {\tzip1\tv[0-9]+\.8h, v[0-9]+\.8h, 
> > v[0-9]+\.8h} } } */
>
> Would be good to make this a scan-assembler-times ... 2.
>
> OK with that change.  Thanks for doing this.
Thanks, committed the patch in:
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=8b18714fbb1ca9812b33b3de75fe6ba4a57d4946
after bootstrap+test on aarch64-linux-gnu, and verifying bootstrap
passes on aarch64-linux-gnu with --enable-checking=all.

Thanks,
Prathamesh
>
> Richard


Re: [PATCH] Machine_Mode: Extend machine_mode from 8 to 16 bits

2023-05-13 Thread Kito Cheng via Gcc-patches
Hi Pan:

Tried this patch and I ran into some issues, some variables are using
unsigned char to hold machine mode and will have problems when the
number of modes is larger than 255...

And here is the fix:


diff --git a/gcc/genmodes.cc b/gcc/genmodes.cc
index 715787b8f483..55ac2adb5596 100644
--- a/gcc/genmodes.cc
+++ b/gcc/genmodes.cc
@@ -1141,10 +1141,10 @@ inline __attribute__((__always_inline__))\n\
#else\n\
extern __inline__ __attribute__((__always_inline__, __gnu_inline__))\n\
#endif\n\
-unsigned char\n\
+unsigned short\n\
mode_inner_inline (machine_mode mode)\n\
{\n\
-  extern const unsigned char mode_inner[NUM_MACHINE_MODES];\n\
+  extern const unsigned short mode_inner[NUM_MACHINE_MODES];\n\
  gcc_assert (mode >= 0 && mode < NUM_MACHINE_MODES);\n\
  switch (mode)\n\
{");
@@ -1529,7 +1529,7 @@ emit_mode_wider (void)
  int c;
  struct mode_data *m;

-  print_decl ("unsigned char", "mode_next", "NUM_MACHINE_MODES");
+  print_decl ("unsigned short", "mode_next", "NUM_MACHINE_MODES");

  for_all_modes (c, m)
tagged_printf ("E_%smode",
@@ -1537,7 +1537,7 @@ emit_mode_wider (void)
  m->name);

  print_closer ();
-  print_decl ("unsigned char", "mode_wider", "NUM_MACHINE_MODES");
+  print_decl ("unsigned short", "mode_wider", "NUM_MACHINE_MODES");

  for_all_modes (c, m)
{
@@ -1568,7 +1568,7 @@ emit_mode_wider (void)
}

  print_closer ();
-  print_decl ("unsigned char", "mode_2xwider", "NUM_MACHINE_MODES");
+  print_decl ("unsigned short", "mode_2xwider", "NUM_MACHINE_MODES");

  for_all_modes (c, m)
{
@@ -1625,7 +1625,7 @@ emit_mode_complex (void)
  int c;
  struct mode_data *m;

-  print_decl ("unsigned char", "mode_complex", "NUM_MACHINE_MODES");
+  print_decl ("unsigned short", "mode_complex", "NUM_MACHINE_MODES");

  for_all_modes (c, m)
tagged_printf ("E_%smode",
@@ -1665,7 +1665,7 @@ emit_mode_inner (void)
  int c;
  struct mode_data *m;

-  print_decl ("unsigned char", "mode_inner", "NUM_MACHINE_MODES");
+  print_decl ("unsigned short", "mode_inner", "NUM_MACHINE_MODES");

  for_all_modes (c, m)
tagged_printf ("E_%smode",
@@ -1738,7 +1738,7 @@ emit_class_narrowest_mode (void)
{
  int c;

-  print_decl ("unsigned char", "class_narrowest_mode", "MAX_MODE_CLASS");
+  print_decl ("unsigned short", "class_narrowest_mode", "MAX_MODE_CLASS");

  for (c = 0; c < MAX_MODE_CLASS; c++)
{
diff --git a/gcc/machmode.h b/gcc/machmode.h
index f1865c1ef425..a168d6f0da2e 100644
--- a/gcc/machmode.h
+++ b/gcc/machmode.h
@@ -24,13 +24,13 @@ typedef opt_mode opt_machine_mode;

extern CONST_MODE_SIZE poly_uint16_pod mode_size[NUM_MACHINE_MODES];
extern CONST_MODE_PRECISION poly_uint16_pod mode_precision[NUM_MACHINE_MODES];
-extern const unsigned char mode_inner[NUM_MACHINE_MODES];
+extern const unsigned short mode_inner[NUM_MACHINE_MODES];
extern CONST_MODE_NUNITS poly_uint16_pod mode_nunits[NUM_MACHINE_MODES];
extern CONST_MODE_UNIT_SIZE unsigned char mode_unit_size[NUM_MACHINE_MODES];
extern const unsigned short mode_unit_precision[NUM_MACHINE_MODES];
-extern const unsigned char mode_next[NUM_MACHINE_MODES];
-extern const unsigned char mode_wider[NUM_MACHINE_MODES];
-extern const unsigned char mode_2xwider[NUM_MACHINE_MODES];
+extern const unsigned short mode_next[NUM_MACHINE_MODES];
+extern const unsigned short mode_wider[NUM_MACHINE_MODES];
+extern const unsigned short mode_2xwider[NUM_MACHINE_MODES];

template
struct mode_traits
@@ -797,7 +797,7 @@ GET_MODE_2XWIDER_MODE (const T )
}

/* Get the complex mode from the component mode.  */
-extern const unsigned char mode_complex[NUM_MACHINE_MODES];
+extern const unsigned short mode_complex[NUM_MACHINE_MODES];
#define GET_MODE_COMPLEX_MODE(MODE) ((machine_mode) mode_complex[MODE])

/* Represents a machine mode that must have a fixed size.  The main
@@ -946,7 +946,7 @@ extern unsigned get_mode_alignment (machine_mode);

/* For each class, get the narrowest mode in that class.  */

-extern const unsigned char class_narrowest_mode[MAX_MODE_CLASS];
+extern const unsigned short class_narrowest_mode[MAX_MODE_CLASS];
#define GET_CLASS_NARROWEST_MODE(CLASS) \
  ((machine_mode) class_narrowest_mode[CLASS])

--
2.39.2


[Bug target/109807] [14 Regression] sse2-mmx-pmaddwd.c met ICE after commit r14-666-g608e7f3ab47 with march=cascadelake

2023-05-13 Thread ubizjak at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109807

Uroš Bizjak  changed:

   What|Removed |Added

 Resolution|FIXED   |DUPLICATE

--- Comment #9 from Uroš Bizjak  ---


*** This bug has been marked as a duplicate of bug 109825 ***

[Bug target/109825] [14 Regression] ICE in ix86_widen_mult_cost, at config/i386/i386.cc:20442 since r14-666-g608e7f3ab47fe7

2023-05-13 Thread ubizjak at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109825

Uroš Bizjak  changed:

   What|Removed |Added

 CC||haochen.jiang at intel dot com

--- Comment #7 from Uroš Bizjak  ---
*** Bug 109807 has been marked as a duplicate of this bug. ***

[Bug libgcc/109712] Segmentation fault in linear_search_fdes

2023-05-13 Thread carlosgalvezp at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109712

--- Comment #6 from Carlos Galvez  ---
Hi again!

I realized there is still one more problem missing, so I suspect the linker was
not the only culprit. It does not segfault, but it gets stuck in an infinite
loop, once again when mixing exceptions and libcudart_static.a.

@Richard you mentioned:

> Does libcudart_static.a by chance contain any symbols from the libgcc runtime 
> (of an old toolchain)?

Do you know how I could verify this? I'm pretty new when it comes to
troubleshooting these things.

My understanding is that libstdc++.so and libgcc_s.so are always backwards
compatible so using "the latest" ensures you can use the newest features and
also run older built code. Is there a flaw/pitfall in that reasoning?

Thanks!

[Bug tree-optimization/106878] [11/12 Regression] ICE: verify_gimple failed at -O2 with pointers and bitwise calculation

2023-05-13 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106878

Andrew Pinski  changed:

   What|Removed |Added

 CC||amonakov at gcc dot gnu.org

--- Comment #16 from Andrew Pinski  ---
*** Bug 109841 has been marked as a duplicate of this bug. ***

[Bug tree-optimization/109841] [12/13/14 Regression] ranger ICE in operator_bitwise_not::fold_range

2023-05-13 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109841

Andrew Pinski  changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |DUPLICATE

--- Comment #2 from Andrew Pinski  ---
/tmp/llvm-project-llvmorg-13.0.1/llvm/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp:61:6:
error: invalid types for ‘bit_not_expr’
uint64_t *
uint64_t *
_92 = ~pretmp_188;
during GIMPLE pass: pre


Yes it is a dup and already fixed in GCC 13.

*** This bug has been marked as a duplicate of bug 106878 ***

[Bug tree-optimization/109841] [12/13/14 Regression] ranger ICE in operator_bitwise_not::fold_range

2023-05-13 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109841

Andrew Pinski  changed:

   What|Removed |Added

   See Also||https://gcc.gnu.org/bugzill
   ||a/show_bug.cgi?id=106878

--- Comment #1 from Andrew Pinski  ---
Hmm, this might actually be fixed in GCC 13 ...

[Bug tree-optimization/109841] [12/13/14 Regression] ranger ICE in operator_bitwise_not::fold_range

2023-05-13 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109841

Andrew Pinski  changed:

   What|Removed |Added

   Target Milestone|--- |12.4

[Bug c++/106943] GCC building clang/llvm with LTO flags causes ICE in clang

2023-05-13 Thread amonakov at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106943

--- Comment #32 from Alexander Monakov  ---
Ranger ICE is PR 109841 (reduced so it doesn't need LTO).

[Bug tree-optimization/109841] New: [12/13/14 Regression] ranger ICE in operator_bitwise_not::fold_range

2023-05-13 Thread amonakov at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109841

Bug ID: 109841
   Summary: [12/13/14 Regression] ranger ICE in
operator_bitwise_not::fold_range
   Product: gcc
   Version: 12.3.0
Status: UNCONFIRMED
  Keywords: ice-on-valid-code
  Severity: normal
  Priority: P3
 Component: tree-optimization
  Assignee: unassigned at gcc dot gnu.org
  Reporter: amonakov at gcc dot gnu.org
  Target Milestone: ---

Created attachment 55076
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55076=edit
compressed testcase

Reduced from gcc-12 LTO ICE on LLVM source code in PR 106943.

g++-12 -O2 -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden 
-std=c++14 -fno-exceptions -fno-rtti -S rbi.ii

during GIMPLE pass: thread
/tmp/llvm-project-llvmorg-13.0.1/llvm/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp:
In member function 'bool llvm::RegisterBankInfo::ValueMapping::verify(unsigned
int) const':
/tmp/llvm-project-llvmorg-13.0.1/llvm/lib/CodeGen/GlobalISel/RegisterBankInfo.cpp:61:6:
internal compiler error: Segmentation fault
   61 | #ifndef NDEBUG
  |  ^
0xda951f crash_signal
../../gcc-12.3.0/gcc/toplev.cc:322
0x1a65ff7 operator_bitwise_not::fold_range(irange&, tree_node*, irange const&,
irange const&, tree_code) const
../../gcc-12.3.0/gcc/range-op.cc:3479
0x1a65ff7 operator_bitwise_not::fold_range(irange&, tree_node*, irange const&,
irange const&, tree_code) const
../../gcc-12.3.0/gcc/range-op.cc:3465
0x198a38a fold_using_range::range_of_range_op(irange&, gimple*, fur_source&)
../../gcc-12.3.0/gcc/gimple-range-fold.cc:608
0x198be60 fold_using_range::fold_stmt(irange&, gimple*, fur_source&,
tree_node*)
../../gcc-12.3.0/gcc/gimple-range-fold.cc:554
0x198c1cc fold_range(irange&, gimple*, range_query*)
../../gcc-12.3.0/gcc/gimple-range-fold.cc:315
0xf0af5d path_range_query::range_of_stmt(irange&, gimple*, tree_node*)
../../gcc-12.3.0/gcc/gimple-range-path.cc:771
0xf0c524 path_range_query::range_defined_in_block(irange&, tree_node*,
basic_block_def*)
../../gcc-12.3.0/gcc/gimple-range-path.cc:356
0xf0c73e path_range_query::internal_range_of_expr(irange&, tree_node*, gimple*)
../../gcc-12.3.0/gcc/gimple-range-path.cc:209
0xf0c73e path_range_query::internal_range_of_expr(irange&, tree_node*, gimple*)
../../gcc-12.3.0/gcc/gimple-range-path.cc:193
0xf0c850 path_range_query::range_of_expr(irange&, tree_node*, gimple*)
../../gcc-12.3.0/gcc/gimple-range-path.cc:225
0x198a13f fold_using_range::range_of_range_op(irange&, gimple*, fur_source&)
../../gcc-12.3.0/gcc/gimple-range-fold.cc:602
0x198be60 fold_using_range::fold_stmt(irange&, gimple*, fur_source&,
tree_node*)
../../gcc-12.3.0/gcc/gimple-range-fold.cc:554
0x198c1cc fold_range(irange&, gimple*, range_query*)
../../gcc-12.3.0/gcc/gimple-range-fold.cc:315
0xf0af5d path_range_query::range_of_stmt(irange&, gimple*, tree_node*)
../../gcc-12.3.0/gcc/gimple-range-path.cc:771
0xf0c524 path_range_query::range_defined_in_block(irange&, tree_node*,
basic_block_def*)
../../gcc-12.3.0/gcc/gimple-range-path.cc:356
0xf0c73e path_range_query::internal_range_of_expr(irange&, tree_node*, gimple*)
../../gcc-12.3.0/gcc/gimple-range-path.cc:209
0xf0c73e path_range_query::internal_range_of_expr(irange&, tree_node*, gimple*)
../../gcc-12.3.0/gcc/gimple-range-path.cc:193
0xf0c850 path_range_query::range_of_expr(irange&, tree_node*, gimple*)
../../gcc-12.3.0/gcc/gimple-range-path.cc:225
0x198a32b fold_using_range::range_of_range_op(irange&, gimple*, fur_source&)
../../gcc-12.3.0/gcc/gimple-range-fold.cc:602

Interesting a binary regression search into the compiler

2023-05-13 Thread Thomas Koenig via Gcc

Hi,

I'm not sure who on this mailing list reads comp.compilers, but there is
an interesting article about built-in regression search in the go
compiler at https://compilers.iecc.com/comparch/article/23-05-003 .

Using a similar approach could also be interesting for gcc,
complementing tools like the regression search and cvise.

Best regards

Thomas



[Bug tree-optimization/107855] gcc.dg/vect/vect-ifcvt-18.c FAILs

2023-05-13 Thread xry111 at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107855

Xi Ruoyao  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2023-05-13
 CC||xry111 at gcc dot gnu.org
 Ever confirmed|0   |1

--- Comment #6 from Xi Ruoyao  ---
Hmm, the test contains

"/* { dg-additional-options "-Ofast -mavx" { target avx_runtime } } */"

So it passes on AVX capable native builds, but fails otherwise.

[Bug middle-end/109840] [14 Regression] internal compiler error: in expand_fn_using_insn, at internal-fn.cc:153 when building graphite2

2023-05-13 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109840

--- Comment #3 from Andrew Pinski  ---
Now the aarch64 backend could add hi and qi patterns for popcount.

For the TARGET_CSSC case, it would need to zero extend to SImode.
For the !TARGET_CSSC case, it would also zero extend but instead to DImode
(just like SImode case).


But I am not 100% sure there might be other backends that would need this.

Now the expansion of the popcount Internal function could do the zero extend
but that is not what the internal function is for ...

[Bug middle-end/109840] [14 Regression] internal compiler error: in expand_fn_using_insn, at internal-fn.cc:153 when building graphite2

2023-05-13 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109840

Andrew Pinski  changed:

   What|Removed |Added

   Last reconfirmed||2023-05-13
   Target Milestone|--- |14.0
Summary|internal compiler error: in |[14 Regression] internal
   |expand_fn_using_insn, at|compiler error: in
   |internal-fn.cc:153 when |expand_fn_using_insn, at
   |building graphite2  |internal-fn.cc:153 when
   ||building graphite2
 Status|UNCONFIRMED |NEW
 Ever confirmed|0   |1
 CC||pinskia at gcc dot gnu.org,
   ||roger at nextmovesoftware dot 
com

--- Comment #2 from Andrew Pinski  ---
(gdb) p debug_gimple_stmt(stmt)
_5 = .POPCOUNT (load_dst_15);


  short unsigned int load_dst_15;

   [local count: 1073741824]:
  load_dst_15 = MEM  [(unsigned char *)_p];
  _5 = .POPCOUNT (load_dst_15);

In forwprop4:
gimple_simplified to _5 = .POPCOUNT (load_dst_15);


Before:
  load_dst_15 = MEM  [(unsigned char *)_p];
  bswapdst_16 = load_dst_15 r>> 8;
  r_14 = (unsigned int) bswapdst_16;
  _5 = .POPCOUNT (r_14);


aarch64 has a popcountsi2 pattern but does not have a popcounthi2 pattern.

Using the internal function here is definitely an issue without checking which
patterns the backend has.

Confirmed.

[Bug middle-end/109840] internal compiler error: in expand_fn_using_insn, at internal-fn.cc:153 when building graphite2

2023-05-13 Thread sjames at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109840

--- Comment #1 from Sam James  ---
Created attachment 55075
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55075=edit
GlyphCache.cpp.ii (reduced)

[Bug middle-end/109840] New: internal compiler error: in expand_fn_using_insn, at internal-fn.cc:153 when building graphite2

2023-05-13 Thread sjames at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109840

Bug ID: 109840
   Summary: internal compiler error: in expand_fn_using_insn, at
internal-fn.cc:153 when building graphite2
   Product: gcc
   Version: 14.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: middle-end
  Assignee: unassigned at gcc dot gnu.org
  Reporter: sjames at gcc dot gnu.org
  Target Milestone: ---

Created attachment 55074
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55074=edit
GlyphCache.cpp.ii.orig

Split out from PR109834
(https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109834#c8).

```
$ aarch64-unknown-linux-gnu-g++ -O2 -c GlyphCache.cpp.ii
during RTL pass: expand
/var/tmp/portage/media-gfx/graphite2-1.3.14_p20210810-r3/work/graphite-80c52493ef42e6fe605a69dcddd2a691cd8a1380/src/GlyphCache.cpp:
In member function ‘const graphite2::GlyphFace*
graphite2::GlyphCache::Loader::read_glyph(short unsigned int,
graphite2::GlyphFace&, int*) const’:
/var/tmp/portage/media-gfx/graphite2-1.3.14_p20210810-r3/work/graphite-80c52493ef42e6fe605a69dcddd2a691cd8a1380/src/GlyphCache.cpp:348:19:
internal compiler error: in expand_fn_using_insn, at internal-fn.cc:153
  348 | const GlyphFace * GlyphCache::Loader::read_glyph(unsigned short
glyphid, GlyphFace & glyph, int *numsubs) const throw()
  |   ^~
0xe8cadf expand_fn_using_insn
   
/usr/src/debug/sys-devel/gcc-14.0.0./gcc-14.0.0./gcc/internal-fn.cc:153
0xbd5407 expand_call_stmt
   
/usr/src/debug/sys-devel/gcc-14.0.0./gcc-14.0.0./gcc/cfgexpand.cc:2737
0xbd5407 expand_gimple_stmt_1
   
/usr/src/debug/sys-devel/gcc-14.0.0./gcc-14.0.0./gcc/cfgexpand.cc:3880
0xbd5407 expand_gimple_stmt
   
/usr/src/debug/sys-devel/gcc-14.0.0./gcc-14.0.0./gcc/cfgexpand.cc:4044
0xbdc793 expand_gimple_basic_block
   
/usr/src/debug/sys-devel/gcc-14.0.0./gcc-14.0.0./gcc/cfgexpand.cc:6106
0xbde4cf execute
   
/usr/src/debug/sys-devel/gcc-14.0.0./gcc-14.0.0./gcc/cfgexpand.cc:6841
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://bugs.gentoo.org/> for instructions.
```

```
gcc (Gentoo 14.0.0. p, commit 29d805847dc870c92f705ed9c5e7eac955c7e7d4)
14.0.0 20230513 (experimental) 99488a6048745a7b999c22f46e5814d02ebf88d9
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
```

[Bug c++/106943] GCC building clang/llvm with LTO flags causes ICE in clang

2023-05-13 Thread amonakov at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106943

--- Comment #31 from Alexander Monakov  ---
(In reply to Xi Ruoyao from comment #28)
> "To put it simply, operator delete for class User inspects memory of the
> object after the end of its lifetime. This shows as a use-after-dtor error
> when running under MemorySanitizer."
> 
> So it seems technically we'll need -fno-lifetime-dse here?  Our docs say
> -flifetime-dse only "preserve stores before the constructor starts" but
> "still treat the object as dead after the destructor".

Agreed, -fno-lifetime-dse seems appropriate here. Thank you for proposing a
patch on the LLVM side!

Re: [PATCH] RISC-V: Improve vector_insn_info::dump for LMUL and policy

2023-05-13 Thread Kito Cheng via Gcc-patches
committed to trunk.

On Sat, May 13, 2023 at 1:13 AM Jeff Law via Gcc-patches
 wrote:
>
>
>
> On 5/12/23 07:32, Kito Cheng via Gcc-patches wrote:
> > Convert vlmul and policy to human readable string, some example below:
> >
> > Before:
> > [VALID,Demand 
> > field={1(VL),0(DEMAND_NONZERO_AVL),1(SEW),0(DEMAND_GE_SEW),1(LMUL),0(RATIO),0(TAIL_POLICY),0(MASK_POLICY)}
> > AVL=(reg:DI 0 zero)
> > SEW=16,VLMUL=3,RATIO=2,TAIL_POLICY=1,MASK_POLICY=1]
> >   ^ ^ ^
> >
> > After:
> > [VALID,Demand 
> > field={1(VL),0(DEMAND_NONZERO_AVL),1(SEW),0(DEMAND_GE_SEW),1(LMUL),0(RATIO),0(TAIL_POLICY),0(MASK_POLICY)}
> > AVL=(reg:DI 0 zero)
> > SEW=16,VLMUL=m8,RATIO=2,TAIL_POLICY=agnostic,MASK_POLICY=agnostic]
> >   ^^  
> >
> > gcc/ChangeLog:
> >
> >   * config/riscv/riscv-vsetvl.cc (vlmul_to_str): New.
> >   (policy_to_str): New.
> >   (vector_insn_info::dump): Use vlmul_to_str and policy_to_str.
> OK
> jeff


  1   2   >