aboutsummaryrefslogtreecommitdiff
path: root/gcc/fold-const.c
diff options
context:
space:
mode:
authorRichard Kenner <kenner@gcc.gnu.org>1996-11-07 07:40:26 -0500
committerRichard Kenner <kenner@gcc.gnu.org>1996-11-07 07:40:26 -0500
commit9898deac71b03c26a1080d077738a32e6107cf28 (patch)
tree081f704500c2854b37367fa24d8384abce19ee4b /gcc/fold-const.c
parent1d58084ae01fd2f03fb2126ae5fcfaa3865fa701 (diff)
downloadgcc-9898deac71b03c26a1080d077738a32e6107cf28.zip
gcc-9898deac71b03c26a1080d077738a32e6107cf28.tar.gz
gcc-9898deac71b03c26a1080d077738a32e6107cf28.tar.bz2
(const_binop, case *_DIV_EXPR): Don't do special sizetype case if a
constant overflows. From-SVN: r13106
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r--gcc/fold-const.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index dabcf29..b3f4365 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -1171,6 +1171,8 @@ const_binop (code, arg1, arg2, notrunc)
and saves time. */
if (int2h == 0 && int2l > 0
&& TREE_TYPE (arg1) == sizetype
+ && ! TREE_CONSTANT_OVERFLOW (arg1)
+ && ! TREE_CONSTANT_OVERFLOW (arg2)
&& int1h == 0 && int1l >= 0)
{
if (code == CEIL_DIV_EXPR)
@@ -1445,18 +1447,14 @@ size_binop (code, arg0, arg1)
if (TREE_CODE (arg0) == INTEGER_CST && TREE_CODE (arg1) == INTEGER_CST)
{
/* And some specific cases even faster than that. */
- if (code == PLUS_EXPR
- && TREE_INT_CST_LOW (arg0) == 0
- && TREE_INT_CST_HIGH (arg0) == 0)
+ if (code == PLUS_EXPR && integer_zerop (arg0))
return arg1;
- if (code == MINUS_EXPR
- && TREE_INT_CST_LOW (arg1) == 0
- && TREE_INT_CST_HIGH (arg1) == 0)
+ else if ((code == MINUS_EXPR || code == PLUS_EXPR)
+ && integer_zerop (arg1))
return arg0;
- if (code == MULT_EXPR
- && TREE_INT_CST_LOW (arg0) == 1
- && TREE_INT_CST_HIGH (arg0) == 0)
+ else if (code == MULT_EXPR && integer_onep (arg0))
return arg1;
+
/* Handle general case of two integer constants. */
return const_binop (code, arg0, arg1, 0);
}