]> gcc.gnu.org Git - gcc.git/commitdiff
narrowing initializers and initializer_constant_valid_p_1
authorRichard Biener <rguenther@suse.de>
Fri, 23 Jun 2023 12:09:47 +0000 (14:09 +0200)
committerRichard Biener <rguenther@suse.de>
Mon, 26 Jun 2023 11:02:35 +0000 (13:02 +0200)
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.

gcc/varasm.cc

index f2a19aa6dbd87a4e3357b403e012d679f4b6e1cf..542315f88cd6cd1622cb399cd6c6e558270c1f83 100644 (file)
@@ -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 };
This page took 0.07122 seconds and 5 git commands to generate.