[PATCH] Fix fold-const typo
Jakub Jelinek
jakub@redhat.com
Wed May 15 13:40:00 GMT 2002
On Wed, May 15, 2002 at 09:15:27AM +0200, Eric Botcazou wrote:
> * fold-const.c (fold) [LT_EXPR]: Move the transformation of a
> comparison against the highest or lowest integer value before
> the 'X >= CST to X > (CST - 1)' and 'X < CST to X <= (CST - 1)'
> transformation and that of an unsigned comparison against 0
> right after.
While at it, I think there is a typo in the code you're moving.
For signed comparisons, instead of testing whether the constant
is minimum signed value (like {CHAR,SHORT,INT,LONG}_MIN) it tests
whether the constant is (say for 32-bit HOST_WIDE_INT and
16-bit comparison 0xffffffff00008000).
E.g. it can be seen say on
short i;
int foo (void)
{
if (i > -32768)
return 1;
return 2;
}
(the code won't be faster in this case, but in more complicated tests it
could).
Bootstrapped on i386-redhat-linux on top of Eric's patch, no regressions.
Ok to commit?
2002-05-15 Jakub Jelinek <jakub@redhat.com>
* fold-const.c (fold): Fix a typo.
--- gcc/fold-const.c.jj Wed May 15 14:02:54 2002
+++ gcc/fold-const.c Wed May 15 14:06:09 2002
@@ -6530,7 +6530,7 @@ fold (expr)
else if (TREE_INT_CST_HIGH (arg1) == -1
&& (TREE_INT_CST_LOW (arg1)
- == ((unsigned HOST_WIDE_INT) 1 << (width - 1)))
+ == ((unsigned HOST_WIDE_INT) -1 << (width - 1)))
&& ! TREE_UNSIGNED (TREE_TYPE (arg1)))
switch (TREE_CODE (t))
{
Jakub
More information about the Gcc-patches
mailing list