public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-2093] narrowing initializers and initializer_constant_valid_p_1
@ 2023-06-26 11:05 Richard Biener
0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2023-06-26 11:05 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:c7b0707ceb24fd10a726780bb42bbbde0c2e06b1
commit r14-2093-gc7b0707ceb24fd10a726780bb42bbbde0c2e06b1
Author: Richard Biener <rguenther@suse.de>
Date: Fri Jun 23 14:09:47 2023 +0200
narrowing initializers and initializer_constant_valid_p_1
initializer_constant_valid_p_1 attempts to handle narrowing
differences and sums but fails to handle when the overall
value looks like
VIEW_CONVERT_EXPR<long long int>(NON_LVALUE_EXPR <v>
- VEC_COND_EXPR < { 0, 0 } == { 0, 0 } , { -1, -1 } , { 0, 0 } > )
where endtype is scalar integer but value is a vector type.
In this particular case all is good and we recurse since
two vector lanes is more than 64bits of long long. But still
it compares apples and oranges.
Fixed by appropriately also requiring the type of the
value to be scalar integral.
* varasm.cc (initializer_constant_valid_p_1): Also
constrain the type of value to be scalar integral
before dispatching to narrowing_initializer_constant_valid_p.
Diff:
---
gcc/varasm.cc | 2 ++
1 file changed, 2 insertions(+)
diff --git a/gcc/varasm.cc b/gcc/varasm.cc
index f2a19aa6dbd..542315f88cd 100644
--- a/gcc/varasm.cc
+++ b/gcc/varasm.cc
@@ -4944,6 +4944,7 @@ initializer_constant_valid_p_1 (tree value, tree endtype, tree *cache)
if (cache && cache[0] == value)
return cache[1];
if (! INTEGRAL_TYPE_P (endtype)
+ || ! INTEGRAL_TYPE_P (TREE_TYPE (value))
|| TYPE_PRECISION (endtype) >= TYPE_PRECISION (TREE_TYPE (value)))
{
tree ncache[4] = { NULL_TREE, NULL_TREE, NULL_TREE, NULL_TREE };
@@ -4980,6 +4981,7 @@ initializer_constant_valid_p_1 (tree value, tree endtype, tree *cache)
if (cache && cache[0] == value)
return cache[1];
if (! INTEGRAL_TYPE_P (endtype)
+ || ! INTEGRAL_TYPE_P (TREE_TYPE (value))
|| TYPE_PRECISION (endtype) >= TYPE_PRECISION (TREE_TYPE (value)))
{
tree ncache[4] = { NULL_TREE, NULL_TREE, NULL_TREE, NULL_TREE };
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-06-26 11:05 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-26 11:05 [gcc r14-2093] narrowing initializers and initializer_constant_valid_p_1 Richard Biener
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).