public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/50319] New: if-conversion produces unvectorizable conditions
@ 2011-09-07 12:13 rguenth at gcc dot gnu.org
  2011-09-07 12:49 ` [Bug tree-optimization/50319] " rguenth at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-09-07 12:13 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 50319
           Summary: if-conversion produces unvectorizable conditions
    Classification: Unclassified
           Product: gcc
           Version: 4.7.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: rguenth@gcc.gnu.org


For

double s1[4], s2[4], s3[64];
void
foo (void)
{
  int i;
  for (i = 0; i < 4; i++)
    s3[0 * 4 + i] = __builtin_isgreater (s1[i], s2[i]) ? -1.0 : 0.0;
  for (i = 0; i < 4; i++)
    s3[1 * 4 + i] = (!__builtin_isgreater (s1[i], s2[i])) ? -1.0 : 0.0;
}

if-conversion generates a) lots of garbage statements, b) it fails to
avoid inversions which causes the code to be non-vectorizable for the
first loop.

Before if-conversion:

<bb 2>:

<bb 3>:
  # i_30 = PHI <i_12(6), 0(2)>
  # ivtmp.7_1 = PHI <ivtmp.7_28(6), 4(2)>
  D.2735_6 = s1[i_30];
  D.2736_7 = s2[i_30];
  if (D.2735_6 u<= D.2736_7)
    goto <bb 5>;
  else
    goto <bb 4>;

<bb 4>:

<bb 5>:
  # iftmp.0_3 = PHI <-1.0e+0(4), 0.0(3)>
  s3[i_30] = iftmp.0_3;
  i_12 = i_30 + 1;
  ivtmp.7_28 = ivtmp.7_1 - 1;
  if (ivtmp.7_28 != 0)
    goto <bb 6>;
  else
    goto <bb 7>;

<bb 6>:
  goto <bb 3>;

after if-conversion:

<bb 3>:
  # i_30 = PHI <i_12(4), 0(2)>
  # ivtmp.7_1 = PHI <ivtmp.7_28(4), 4(2)>
  D.2735_6 = s1[i_30];
  D.2736_7 = s2[i_30];
  D.2760_34 = D.2735_6 u<= D.2736_7;
  D.2761_35 = ~D.2760_34;
  iftmp.0_3 = D.2761_35 ? -1.0e+0 : 0.0;
  s3[i_30] = iftmp.0_3;
  i_12 = i_30 + 1;
  ivtmp.7_28 = ivtmp.7_1 - 1;
  D.2762_36 = D.2735_6 u<= D.2736_7;
  D.2763_37 = D.2762_36 | D.2761_35;
  if (ivtmp.7_28 != 0)
    goto <bb 4>;
  else
    goto <bb 5>;

the statements computing D.2762_36 and D.2763_37 are dead.  The statement
computing D.2761_35 can be avoided by swapping the arms of the generated
cond-expr.

if-conversion tries to do this but fails for numerous reasons in
find_phi_replacement_condition.


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

* [Bug tree-optimization/50319] if-conversion produces unvectorizable conditions
  2011-09-07 12:13 [Bug tree-optimization/50319] New: if-conversion produces unvectorizable conditions rguenth at gcc dot gnu.org
@ 2011-09-07 12:49 ` rguenth at gcc dot gnu.org
  2011-09-07 14:22 ` rguenth at gcc dot gnu.org
  2011-09-07 15:07 ` rguenth at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-09-07 12:49 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2011-09-07
         AssignedTo|unassigned at gcc dot       |rguenth at gcc dot gnu.org
                   |gnu.org                     |
     Ever Confirmed|0                           |1

--- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-09-07 12:41:35 UTC ---
I have a patch.


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

* [Bug tree-optimization/50319] if-conversion produces unvectorizable conditions
  2011-09-07 12:13 [Bug tree-optimization/50319] New: if-conversion produces unvectorizable conditions rguenth at gcc dot gnu.org
  2011-09-07 12:49 ` [Bug tree-optimization/50319] " rguenth at gcc dot gnu.org
@ 2011-09-07 14:22 ` rguenth at gcc dot gnu.org
  2011-09-07 15:07 ` rguenth at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-09-07 14:22 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-09-07 14:19:38 UTC ---
Author: rguenth
Date: Wed Sep  7 14:19:33 2011
New Revision: 178638

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=178638
Log:
2011-09-07  Richard Guenther  <rguenther@suse.de>

    PR tree-optimization/50319
    * tree-if-conv.c (set_bb_predicate): Assert we only set
    canonical predicates.
    (add_to_predicate_list): Simplify.  Allow TRUTH_NOT_EXPR
    around canonical predicates.
    (predicate_bbs): Do not re-gimplify already canonical
    predicates.  Properly unshare them though.
    (find_phi_replacement_condition): Simplify.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/tree-if-conv.c


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

* [Bug tree-optimization/50319] if-conversion produces unvectorizable conditions
  2011-09-07 12:13 [Bug tree-optimization/50319] New: if-conversion produces unvectorizable conditions rguenth at gcc dot gnu.org
  2011-09-07 12:49 ` [Bug tree-optimization/50319] " rguenth at gcc dot gnu.org
  2011-09-07 14:22 ` rguenth at gcc dot gnu.org
@ 2011-09-07 15:07 ` rguenth at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-09-07 15:07 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED

--- Comment #3 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-09-07 15:05:08 UTC ---
Fixed.


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

end of thread, other threads:[~2011-09-07 15:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-07 12:13 [Bug tree-optimization/50319] New: if-conversion produces unvectorizable conditions rguenth at gcc dot gnu.org
2011-09-07 12:49 ` [Bug tree-optimization/50319] " rguenth at gcc dot gnu.org
2011-09-07 14:22 ` rguenth at gcc dot gnu.org
2011-09-07 15:07 ` rguenth 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).