Hi!

For Ada with LTO, boolean_{false,true}_node can be 1-bit precision boolean,
while TREE_TYPE (lhs) can be 8-bit precision boolean and thus we can end up
with wide_int mismatches.

The following patch fixes it by using TYPE_{MIN,MAX}_VALUE instead.

Bootstrapped/regtested on x86_64-linux and i686-linux (the former including
Ada as usually), ok for trunk?
Or do you prefer your version with wi::zero/wi::one?

2020-12-09  Jakub Jelinek  <ja...@redhat.com>

        PR bootstrap/98188
        * tree-ssa-phiopt.c (two_value_replacement): For boolean, set
        min and max from minimum and maximum of the type.

--- gcc/tree-ssa-phiopt.c.jj    2020-12-06 10:57:00.142847537 +0100
+++ gcc/tree-ssa-phiopt.c       2020-12-08 15:00:09.091063392 +0100
@@ -660,8 +660,8 @@ two_value_replacement (basic_block cond_
   wide_int min, max;
   if (TREE_CODE (TREE_TYPE (lhs)) == BOOLEAN_TYPE)
     {
-      min = wi::to_wide (boolean_false_node);
-      max = wi::to_wide (boolean_true_node);
+      min = wi::to_wide (TYPE_MIN_VALUE (TREE_TYPE (lhs)));
+      max = wi::to_wide (TYPE_MAX_VALUE (TREE_TYPE (lhs)));
     }
   else if (get_range_info (lhs, &min, &max) != VR_RANGE)
     return false;

        Jakub

Reply via email to