public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/65217] __builtin_unreachable in if statement causes bad assembly generation
Date: Mon, 27 Apr 2015 11:08:00 -0000	[thread overview]
Message-ID: <bug-65217-4-UkNI6ckY5K@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-65217-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65217

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |missed-optimization, xfail
             Status|RESOLVED                    |REOPENED
   Last reconfirmed|                            |2015-04-27
                 CC|                            |law at gcc dot gnu.org,
                   |                            |rguenth at gcc dot gnu.org
          Component|c                           |tree-optimization
         Resolution|FIXED                       |---
     Ever confirmed|0                           |1

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
It was only fixed by luck due to us folding all stmts in forwprop which turns

  if (_3 != n_1(D))

into the canonical

  if (n_1(D) != _3)

and then DOM recording the "proper" equality via record_equality by _always_
swapping operands due to

  else if (is_gimple_min_invariant (x)
           /* ???  When threading over backedges the following is important
              for correctness.  See PR61757.  */
           || (loop_depth_of_name (x) <= loop_depth_of_name (y)))

and its '==' part.

For non-canonical order (in GCC 4.9 and earlier) that swapping turned it into
the unfortunate direction.

That equality decides whether we propagate _3 into the return value on the
else branch (where n_1(D) == _3) or leave it as n_1(D) (good for this case).

I am about to commit a patch that does not perform this kind of random swapping
(and will XFAIL the testcase).


  parent reply	other threads:[~2015-04-27 11:08 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-26  7:37 [Bug c/65217] New: " sumnon at cj3 dot org
2015-02-26  7:39 ` [Bug c/65217] " pinskia at gcc dot gnu.org
2015-02-26 15:04 ` hjl at gcc dot gnu.org
2015-04-27 11:08 ` rguenth at gcc dot gnu.org [this message]
2015-04-28  4:02 ` [Bug tree-optimization/65217] " law at gcc dot gnu.org
2015-04-28 14:26 ` law at redhat dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-65217-4-UkNI6ckY5K@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).