From: Andrew MacLeod <amacleod@redhat.com>
To: gcc-patches <gcc-patches@gcc.gnu.org>,
Richard Biener <richard.guenther@gmail.com>,
Jeff Law <jeffreyalaw@gmail.com>,
Aldy Hernandez <aldyh@redhat.com>
Subject: how does vrp2 rearrange this?
Date: Tue, 19 Oct 2021 16:28:13 -0400 [thread overview]
Message-ID: <9e681d3f-9c02-f244-8969-c0f55316cc06@redhat.com> (raw)
using testcase ifcvt-4.c:
typedef int word __attribute__((mode(word)));
word
foo (word x, word y, word a)
{
word i = x;
word j = y;
/* Try to make taking the branch likely. */
__builtin_expect (x > y, 1);
if (x > y)
{
i = a;
j = i;
}
return i * j;
The current VRP2 pass takes:
if (x_3(D) > y_4(D))
goto <bb 3>; [50.00%] <<--- note the THEN target
else
goto <bb 4>; [50.00%]
;; succ: 3 [50.0% (guessed)] count:536870912 (estimated
locally) (TRUE_VALUE,EXECUTABLE)
;; 4 [50.0% (guessed)] count:536870912 (estimated
locally) (FALSE_VALUE,EXECUTABLE)
;; basic block 3, loop depth 0, count 536870912 (estimated locally),
maybe hot
;; prev block 2, next block 4, flags: (NEW, REACHABLE, VISITED)
;; pred: 2 [50.0% (guessed)] count:536870912 (estimated
locally) (TRUE_VALUE,EXECUTABLE)
;; succ: 4 [always] count:536870912 (estimated locally)
(FALLTHRU,EXECUTABLE)
;; basic block 4, loop depth 0, count 1073741824 (estimated locally),
maybe hot
;; prev block 3, next block 1, flags: (NEW, REACHABLE, VISITED)
;; pred: 2 [50.0% (guessed)] count:536870912 (estimated
locally) (FALSE_VALUE,EXECUTABLE)
;; 3 [always] count:536870912 (estimated locally)
(FALLTHRU,EXECUTABLE)
# i_1 = PHI <x_3(D)(2), a_5(D)(3)>
# j_2 = PHI <y_4(D)(2), a_5(D)(3)>
_6 = i_1 * j_2;
# VUSE <.MEM_7(D)>
return _6;
and turns it into :
;; basic block 2, loop depth 0, count 1073741824 (estimated locally),
maybe hot
;; prev block 0, next block 3, flags: (NEW, REACHABLE, VISITED)
;; pred: ENTRY [always] count:1073741824 (estimated locally)
(FALLTHRU,EXECUTABLE)
if (x_3(D) > y_4(D))
goto <bb 4>; [50.00%] <<-- has been reversed.
else
goto <bb 3>; [50.00%]
;; succ: 4 [50.0% (guessed)] count:536870912 (estimated
locally) (TRUE_VALUE,EXECUTABLE)
;; 3 [50.0% (guessed)] count:536870912 (estimated
locally) (FALSE_VALUE,EXECUTABLE)
;; basic block 3, loop depth 0, count 536870912 (estimated locally),
maybe hot
;; prev block 2, next block 4, flags: (NEW, VISITED)
;; pred: 2 [50.0% (guessed)] count:536870912 (estimated
locally) (FALSE_VALUE,EXECUTABLE)
;; succ: 4 [always] count:536870912 (estimated locally)
(FALLTHRU,EXECUTABLE)
;; basic block 4, loop depth 0, count 1073741824 (estimated locally),
maybe hot
;; prev block 3, next block 1, flags: (NEW, REACHABLE, VISITED)
;; pred: 3 [always] count:536870912 (estimated locally)
(FALLTHRU,EXECUTABLE)
;; 2 [50.0% (guessed)] count:536870912 (estimated
locally) (TRUE_VALUE,EXECUTABLE)
# i_1 = PHI <x_3(D)(3), a_5(D)(2)>
# j_2 = PHI <y_4(D)(3), a_5(D)(2)>
_6 = i_1 * j_2;
# VUSE <.MEM_7(D)>
return _6;
So the IF has reversed the targets (but not the condition), and the PHIs
in the target block have been adjusted.
Where does this happen? I cannot find it. There doesnt seem to be
anything in the IL which is reflecting the "expect" from the original
code.. and if I run ranger vrp instead of classic_vrp, we don't do
this... so I'm missing something....
Thanks
Andrew
next reply other threads:[~2021-10-19 20:28 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-19 20:28 Andrew MacLeod [this message]
2021-10-19 21:13 ` Andrew Pinski
2021-10-19 22:32 ` Andrew MacLeod
2021-10-19 23:13 ` Andrew Pinski
2021-10-21 15:03 ` Andrew MacLeod
2021-10-21 19:59 ` Andrew Pinski
2021-10-25 15:43 ` Andrew MacLeod
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=9e681d3f-9c02-f244-8969-c0f55316cc06@redhat.com \
--to=amacleod@redhat.com \
--cc=aldyh@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jeffreyalaw@gmail.com \
--cc=richard.guenther@gmail.com \
/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).