diff options
author | Richard Kenner <kenner@gcc.gnu.org> | 1993-08-16 18:47:39 -0400 |
---|---|---|
committer | Richard Kenner <kenner@gcc.gnu.org> | 1993-08-16 18:47:39 -0400 |
commit | 79bf94d3eacbf86c33bfc191e4a26cdae9ae767d (patch) | |
tree | 669de41aa81a66a2d1424c4fa4b2d06250244cb8 /gcc | |
parent | 41fe0b83ba0c830077b46e8386065204fcd4fd6e (diff) | |
download | gcc-79bf94d3eacbf86c33bfc191e4a26cdae9ae767d.zip gcc-79bf94d3eacbf86c33bfc191e4a26cdae9ae767d.tar.gz gcc-79bf94d3eacbf86c33bfc191e4a26cdae9ae767d.tar.bz2 |
(fold...
(fold, case EQ_EXPR): Re-enable converting signed MOD operations to
unsigned when inside comparisons against zero, but only when the
second operand of the MOD is an integral power of two.
From-SVN: r5166
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/fold-const.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index e3eab5b..9d5aecc 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -4224,20 +4224,17 @@ fold (expr) arg1)); } - /* It would be nice to do this since it generates better code. - Unfortunately, it doesn't produce the correct result if the - first operand is negative. */ -#if 0 /* If this is an NE or EQ comparison of zero against the result of a - signed MOD operation, make the MOD operation unsigned since it - is simpler and equivalent. */ + signed MOD operation whose second operand is a power of 2, make + the MOD operation unsigned since it is simpler and equivalent. */ if ((code == NE_EXPR || code == EQ_EXPR) && integer_zerop (arg1) && ! TREE_UNSIGNED (TREE_TYPE (arg0)) && (TREE_CODE (arg0) == TRUNC_MOD_EXPR || TREE_CODE (arg0) == CEIL_MOD_EXPR || TREE_CODE (arg0) == FLOOR_MOD_EXPR - || TREE_CODE (arg0) == ROUND_MOD_EXPR)) + || TREE_CODE (arg0) == ROUND_MOD_EXPR) + && integer_pow2p (TREE_OPERAND (arg0, 1))) { tree newtype = unsigned_type (TREE_TYPE (arg0)); tree newmod = build (TREE_CODE (arg0), newtype, @@ -4246,7 +4243,6 @@ fold (expr) return build (code, type, newmod, convert (newtype, arg1)); } -#endif /* If this is an NE comparison of zero with an AND of one, remove the comparison since the AND will give the correct value. */ |