Jeff or Richard,
As the two middle end maintainers familiar with my work, can one
of you approve the updated patch? It's necessary to restore ILP32
bootstrap on a number of targets (pr77676).
https://gcc.gnu.org/ml/gcc-patches/2016-09/msg01477.html
Thanks
Martin
On 09/21/2016 06:28 PM, Martin Sebor wrote:
On 09/21/2016 05:09 PM, Jakub Jelinek wrote:
On Wed, Sep 21, 2016 at 04:39:42PM -0600, Martin Sebor wrote:
diff --git a/gcc/gimple-ssa-sprintf.c b/gcc/gimple-ssa-sprintf.c
index dddb026..652d3fb 100644
--- a/gcc/gimple-ssa-sprintf.c
+++ b/gcc/gimple-ssa-sprintf.c
@@ -210,8 +210,8 @@ struct format_result
static HOST_WIDE_INT
target_int_min ()
{
- static const unsigned HOST_WIDE_INT int_min
- = 1LLU << (sizeof int_min * CHAR_BIT
+ const unsigned HOST_WIDE_INT int_min
+ = 1LLU << (HOST_BITS_PER_WIDE_INT
1LLU should be really HOST_WIDE_INT_1U
- TYPE_PRECISION (integer_type_node) + 1);
Is the shift amount really what you mean?
HOST_BITS_PER_WIDE_INT - TYPE_PRECISION (integer_type_node) + 1
is usually 33 (or 17 or 9 in much rarer cases), so that is
0x200000000ULL. Don't you want instead
= HOST_WIDE_INT_1U << (TYPE_PRECISION (ingeger_type_node) - 1);
so that it will be
0x80000000ULL?
Great catch, thank you! That must have been a copy and paste mistake.
@@ -221,8 +221,8 @@ target_int_min ()
static unsigned HOST_WIDE_INT
target_int_max ()
{
- static const unsigned HOST_WIDE_INT int_max
- = HOST_WIDE_INT_M1U >> (sizeof int_max * CHAR_BIT
+ const unsigned HOST_WIDE_INT int_max
+ = HOST_WIDE_INT_M1U >> (HOST_BITS_PER_WIDE_INT
- TYPE_PRECISION (integer_type_node) + 1);
return int_max;
}
This is expectedly -1ULL >> 33, i.e. 0x7fffffffULL, which looks ok.
Thanks for double checking that. There is a test case for this
in the test suite for the optimization but there wasn't one for
the INT_MIN case. I've added it in the attached patch. I'll
beef up the return range testing some more before re-enabling
the optimization.
Martin