public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* how does vrp2 rearrange this?
@ 2021-10-19 20:28 Andrew MacLeod
  2021-10-19 21:13 ` Andrew Pinski
  0 siblings, 1 reply; 7+ messages in thread
From: Andrew MacLeod @ 2021-10-19 20:28 UTC (permalink / raw)
  To: gcc-patches, Richard Biener, Jeff Law, Aldy Hernandez

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


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

end of thread, other threads:[~2021-10-25 15:43 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-19 20:28 how does vrp2 rearrange this? Andrew MacLeod
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

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