]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix tree_simple_nonnegative_warnv_p for VECTOR_TYPEs
authorRichard Biener <rguenther@suse.de>
Fri, 23 Jun 2023 08:12:24 +0000 (10:12 +0200)
committerRichard Biener <rguenther@suse.de>
Fri, 23 Jun 2023 09:23:57 +0000 (11:23 +0200)
tree_simple_nonnegative_warnv_p ends up being called on VECTOR_TYPEs
which I think even gets the wrong answer here for tcc_comparison
since vector bools are signed.  The following properly guards
that with !VECTOR_TYPE_P.

* fold-const.cc (tree_simple_nonnegative_warnv_p): Guard
the truth_value_p case with !VECTOR_TYPE_P.

gcc/fold-const.cc

index b05b3ae16e938eb6814b40500258af7af787de42..ac90a594fcc48d740cebfb4cb9eb81372aa24c2a 100644 (file)
@@ -14530,7 +14530,8 @@ tree_expr_maybe_real_minus_zero_p (const_tree x)
 static bool
 tree_simple_nonnegative_warnv_p (enum tree_code code, tree type)
 {
-  if ((TYPE_PRECISION (type) != 1 || TYPE_UNSIGNED (type))
+  if (!VECTOR_TYPE_P (type)
+      && (TYPE_PRECISION (type) != 1 || TYPE_UNSIGNED (type))
       && truth_value_p (code))
     /* Truth values evaluate to 0 or 1, which is nonnegative unless we
        have a signed:1 type (where the value is -1 and 0).  */