public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/64454] New: optimize (x%5)%5
@ 2014-12-31 12:25 glisse at gcc dot gnu.org
  2015-01-02 20:35 ` [Bug tree-optimization/64454] " glisse at gcc dot gnu.org
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: glisse at gcc dot gnu.org @ 2014-12-31 12:25 UTC (permalink / raw)
  To: gcc-bugs

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).


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2022-02-24 10:33 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-31 12:25 [Bug tree-optimization/64454] New: optimize (x%5)%5 glisse at gcc dot gnu.org
2015-01-02 20:35 ` [Bug tree-optimization/64454] " glisse at gcc dot gnu.org
2015-01-12 17:54 ` jakub at gcc dot gnu.org
2015-01-12 19:53 ` glisse at gcc dot gnu.org
2015-01-12 20:45 ` jakub at gcc dot gnu.org
2015-01-12 20:52 ` jakub at gcc dot gnu.org
2015-01-12 21:16 ` jakub at gcc dot gnu.org
2015-05-01 10:21 ` glisse at gcc dot gnu.org
2015-05-09 15:40 ` glisse at gcc dot gnu.org
2015-05-15 17:40 ` glisse at gcc dot gnu.org
2015-05-15 18:07 ` pinskia at gcc dot gnu.org
2015-05-15 18:30 ` glisse at gcc dot gnu.org
2022-02-24 10:33 ` pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).