This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/64454] New: optimize (x%5)%5
- From: "glisse at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 31 Dec 2014 12:24:56 +0000
- Subject: [Bug tree-optimization/64454] New: optimize (x%5)%5
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64454
Bug ID: 64454
Summary: optimize (x%5)%5
Product: gcc
Version: 5.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: glisse at gcc dot gnu.org
unsigned f(unsigned x){
return (x%5)%5;
}
gives:
_2 = x_1(D) % 5;
_3 = _2 % 5;
return _3;
It seems we could easily do better in 2 ways:
1) (x%y)%y could be simplified to x%y in match.pd. This would work even when y
is not a constant.
2) with VRP, depending on the interval for x, we may be able to simplify x%CST
to just x (or sometimes x+CST).