public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/58728] New: [missed optimization] == or != comparisons may affect range test optimization.
@ 2013-10-14 20:04 congh at google dot com
  2013-10-21 18:39 ` [Bug tree-optimization/58728] " congh at google dot com
  2013-10-21 18:41 ` paolo.carlini at oracle dot com
  0 siblings, 2 replies; 3+ messages in thread
From: congh at google dot com @ 2013-10-14 20:04 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58728

            Bug ID: 58728
           Summary: [missed optimization] == or != comparisons may affect
                    range test optimization.
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: congh at google dot com

Created attachment 31002
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31002&action=edit
Patch

Look at the following code:


int foo(unsigned int n)
{
  if (n != 0)
  if (n != 1)
  if (n != 2)
  if (n != 3)
  if (n != 4)
    return ++n;
  return n;
}


Those five comparisons should be able to be merged into one during range test
optimization but they are not. The reason is that GCC checks the phi args of n
after the branch to make sure two false edges of two neighboring ifs define the
same phi arg at the join node (thus guarantees side-effect free). However, the
"vrp" pass replaced the phi arg by the identical value of the original phi arg
deducted from == or != comparisons, hence preventing the range test
optimization.

The same case is in if-combine pass.

I made a patch for this issue which is attached here.


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

* [Bug tree-optimization/58728] [missed optimization] == or != comparisons may affect range test optimization.
  2013-10-14 20:04 [Bug tree-optimization/58728] New: [missed optimization] == or != comparisons may affect range test optimization congh at google dot com
@ 2013-10-21 18:39 ` congh at google dot com
  2013-10-21 18:41 ` paolo.carlini at oracle dot com
  1 sibling, 0 replies; 3+ messages in thread
From: congh at google dot com @ 2013-10-21 18:39 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58728

--- Comment #1 from Cong Hou <congh at google dot com> ---
Any comment on this?


thanks,
Cong


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

* [Bug tree-optimization/58728] [missed optimization] == or != comparisons may affect range test optimization.
  2013-10-14 20:04 [Bug tree-optimization/58728] New: [missed optimization] == or != comparisons may affect range test optimization congh at google dot com
  2013-10-21 18:39 ` [Bug tree-optimization/58728] " congh at google dot com
@ 2013-10-21 18:41 ` paolo.carlini at oracle dot com
  1 sibling, 0 replies; 3+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-10-21 18:41 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58728

--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Yes: patches should be submitted to the gcc-patches mailing list.


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

end of thread, other threads:[~2013-10-21 18:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-14 20:04 [Bug tree-optimization/58728] New: [missed optimization] == or != comparisons may affect range test optimization congh at google dot com
2013-10-21 18:39 ` [Bug tree-optimization/58728] " congh at google dot com
2013-10-21 18:41 ` paolo.carlini at oracle dot com

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