This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH] Fix extract_muldiv (PR tree-optimization/56899)
- From: Jeff Law <law at redhat dot com>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: Richard Biener <rguenther at suse dot de>, gcc-patches at gcc dot gnu dot org
- Date: Wed, 10 Apr 2013 12:38:26 -0600
- Subject: Re: [PATCH] Fix extract_muldiv (PR tree-optimization/56899)
- References: <20130410153114 dot GE16463 at tucnak dot redhat dot com>
On 04/10/2013 09:31 AM, Jakub Jelinek wrote:
OK, but I think you should update the comment before the test. Right
now it just references the overflow of the constant multiplication.
As f1 in the testcase shows, applying distributive law in extract_muldiv_1
isn't safe if overflow behavior isn't defined, if we have
(op0 + c1) * c2
and the type is signed, we can't just try to fold that to
op0 * c2 + (c1 * c2)
even when we know that c1*c2 doesn't overflow, because op0 * c2
might overflow even when (op0 + c1) * c2 doesn't.
Fixed thusly, after all that hunk of code is often soon undone by
fold_build2 again or later during GIMPLE optimizations,
bootstrapped/regtested on x86_64-linux and i686-linux, ok
2013-04-10 Jakub Jelinek <firstname.lastname@example.org>
* fold-const.c (extract_muldiv_1): Apply distributive law
only if TYPE_OVERFLOW_WRAPS (ctype).
* gcc.c-torture/execute/pr56899.c: New test.