Since all computations in tree-object-size are now done in sizetype and
not HOST_WIDE_INT, comparisons after conversion to HOST_WIDE_INT would
be incorrect.  Instead, truncate unknown (object_size_type) to sizetype
to compare with the computed size to evaluate if it is unknown.

gcc/ChangeLog:

        PR tree-optimization/103759
        * tree-object-size (size_unknown_p): Construct a size_unknown
        and compare with VAL.

Signed-off-by: Siddhesh Poyarekar <siddh...@gotplt.org>
---
This fixes all the 32-bit torture failures on i686, tested with
configuration:

--enable-clocale=gnu --with-system-zlib --enable-shared --enable-cet
--with-demangler-in-ld --enable-libmpx i686-linux --with-fpmath=sse
--enable-languages=c,c++,lto --disable-bootstrap

and also with x86_64 to ensure I didn't regress there.  I have a full
bootstrap build and test run in progress.

 gcc/tree-object-size.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/gcc/tree-object-size.c b/gcc/tree-object-size.c
index 71f6b747d05..71c7935cb07 100644
--- a/gcc/tree-object-size.c
+++ b/gcc/tree-object-size.c
@@ -100,15 +100,6 @@ unknown (int object_size_type)
   return ~initval (object_size_type);
 }
 
-/* Return true if VAL is represents an unknown size for OBJECT_SIZE_TYPE.  */
-
-static inline bool
-size_unknown_p (tree val, int object_size_type)
-{
-  return (tree_fits_uhwi_p (val)
-         && tree_to_uhwi (val) == unknown (object_size_type));
-}
-
 /* Return a tree with initial value for OBJECT_SIZE_TYPE.  */
 
 static inline tree
@@ -125,6 +116,15 @@ size_unknown (int object_size_type)
   return size_int (unknown (object_size_type));
 }
 
+/* Return true if VAL is represents an unknown size for OBJECT_SIZE_TYPE.  */
+
+static inline bool
+size_unknown_p (tree val, int object_size_type)
+{
+  return (TREE_CODE (val) == INTEGER_CST
+         && tree_int_cst_compare (val, size_unknown (object_size_type)));
+}
+
 /* Grow object_sizes[OBJECT_SIZE_TYPE] to num_ssa_names.  */
 
 static inline void
-- 
2.31.1

Reply via email to