]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
fold-const: Handle BITINT_TYPE in range_check_type
authorJakub Jelinek <jakub@redhat.com>
Tue, 12 Sep 2023 11:08:54 +0000 (13:08 +0200)
committerJakub Jelinek <jakub@redhat.com>
Tue, 12 Sep 2023 11:08:54 +0000 (13:08 +0200)
When discussing PR111369 with Andrew Pinski, I've realized that
I haven't added BITINT_TYPE handling to range_check_type.  Right now
(unsigned) max + 1 == (unsigned) min for signed _BitInt,l so I think we
don't need to do the extra hops for BITINT_TYPE (though possibly we don't
need them for INTEGER_TYPE either in the two's complement word and we don't
support anything else, though I really don't know if Ada or some other
FEs don't create weird INTEGER_TYPEs).

2023-09-12  Jakub Jelinek  <jakub@redhat.com>

* fold-const.cc (range_check_type): Handle BITINT_TYPE like
OFFSET_TYPE.

gcc/fold-const.cc

index d19b4666c6521e08736a70dadb421c0f6e54aaf9..c5ac82200c8e0f2fcb69c315165a5d860c91a631 100644 (file)
@@ -5565,7 +5565,12 @@ range_check_type (tree etype)
       else
        return NULL_TREE;
     }
-  else if (POINTER_TYPE_P (etype) || TREE_CODE (etype) == OFFSET_TYPE)
+  else if (POINTER_TYPE_P (etype)
+          || TREE_CODE (etype) == OFFSET_TYPE
+          /* Right now all BITINT_TYPEs satisfy
+             (unsigned) max + 1 == (unsigned) min, so no need to verify
+             that like for INTEGER_TYPEs.  */
+          || TREE_CODE (etype) == BITINT_TYPE)
     etype = unsigned_type_for (etype);
   return etype;
 }