Commit b77f3744 by Christian Ehrhardt Committed by Richard Henderson

re PR c/8639 (simple integer arithmetic expression broken)

        PR c/8639
        * fold-const.c (extract_muldiv): Don't propagate division unless
        both arguments are multiples of C.
	* gcc.c-torture/execute/20021119-1.c: New.

From-SVN: r59466
parent f815521c
2002-11-25 Christian Ehrhardt <ehrhardt@mathematik.uni-ulm.de>
PR c/8639
* fold-const.c (extract_muldiv): Don't propagate division unless
both arguments are multiples of C.
2002-11-25 Andrew Haley <aph@redhat.com>
* libgcc-std.ver (_Unwind_Find_Enclosing_Function): Add.
......
......@@ -4178,10 +4178,10 @@ extract_muldiv (t, c, code, wide_type)
t2 = extract_muldiv (op1, c, code, wide_type);
if (t1 != 0 && t2 != 0
&& (code == MULT_EXPR
/* If not multiplication, we can only do this if either operand
is divisible by c. */
|| multiple_of_p (ctype, op0, c)
|| multiple_of_p (ctype, op1, c)))
/* If not multiplication, we can only do this if both operands
are divisible by c. */
|| (multiple_of_p (ctype, op0, c)
&& multiple_of_p (ctype, op1, c))))
return fold (build (tcode, ctype, convert (ctype, t1),
convert (ctype, t2)));
......
/* PR 8639. */
extern void abort(void);
int foo (int i)
{
int r;
r = (80 - 4 * i) / 20;
return r;
}
int main ()
{
if (foo (1) != 3)
abort ();
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment