Bug 35307 - Missing Simplication for div op
Missing Simplication for div op
Status: NEW
Product: gcc
Classification: Unclassified
Component: middle-end
4.3.0
: P3 enhancement
: ---
Assigned To: Not yet assigned to anyone
: missed-optimization
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2008-02-23 05:17 UTC by davidxl
Modified: 2008-12-29 06:42 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2008-12-29 06:42:56


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description davidxl 2008-02-23 05:17:04 UTC
The following rule is good to have:

int i, i, k;

  i/j/k ===>  i/(j*k)
Comment 1 Segher Boessenkool 2008-02-23 19:57:18 UTC
Not equivalent in the presence of overflow.
Comment 2 Andrew Pinski 2008-02-23 20:00:59 UTC
(In reply to comment #1)
> Not equivalent in the presence of overflow.

You mean defined overflow :).
Comment 3 Segher Boessenkool 2008-02-26 16:16:47 UTC
> > Not equivalent in the presence of overflow.
> 
> You mean defined overflow :).

No, I mean overflow.

Let's assume int is 16-bit (just to keep the numbers smallish);
now take i=1, j=1000, k=1000.  i/j/k is perfectly well-defined,
but i/(j*k) overflows in the j*k computation.


Segher