public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug optimization/14846] New: [tree-ssa] don't use a shift in A & CST_POWER_OF_2 == 0 until very late in tree-ssa optimizations
@ 2004-04-04 16:47 kazu at cs dot umass dot edu
  2004-04-04 16:55 ` [Bug optimization/14846] " kazu at cs dot umass dot edu
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: kazu at cs dot umass dot edu @ 2004-04-04 16:47 UTC (permalink / raw)
  To: gcc-bugs

I wonder if the shift in (a >> 3) & 1 == 0 does any good for tree-ssa.

Consider:

void bar (void);

void
foo (unsigned int a)
{
  if ((a & 8) != 0)
    bar ();
}

I get:

  T.0_2 = a_1 >> 3;
  T.1_3 = (int)T.0_2;
  T.2_4 = T.1_3 & 1;
  T.3_5 = (_Bool)T.2_4;
  if (T.3_5) goto <L0>; else goto <L1>;

Even if Andrew Pinski removes the _Bool and int cast,

  T.0_2 = a_1 >> 3;
  T.2_4 = T.0_2 & 1;
  if (T.2_4 != 0) goto <L0>; else goto <L1>;

Without the shift,

  T.2_4 = a_1 & 1;
  if (T.2_4 != 0) goto <L0>; else goto <L1>;

Without the shift, it's a lot easier to combine two consecutive bit tests like

  if (a & 1) goto there;
  if (a & 4) goto there;

into

  if (a & 5) goto there;

Removing the shift should also make it easier to solve PR 14752
because we don't have to look as many statements to do the optimization.

If we need the shift for some machine-specific reasons,
we should introduce it very late in tree-ssa optimizations or at expand time.

-- 
           Summary: [tree-ssa] don't use a shift in A & CST_POWER_OF_2 == 0
                    until very late in tree-ssa optimizations
           Product: gcc
           Version: tree-ssa
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P2
         Component: optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: kazu at cs dot umass dot edu
                CC: gcc-bugs at gcc dot gnu dot org


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


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

end of thread, other threads:[~2005-04-21  0:40 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-04-04 16:47 [Bug optimization/14846] New: [tree-ssa] don't use a shift in A & CST_POWER_OF_2 == 0 until very late in tree-ssa optimizations kazu at cs dot umass dot edu
2004-04-04 16:55 ` [Bug optimization/14846] " kazu at cs dot umass dot edu
2004-04-04 16:56 ` kazu at cs dot umass dot edu
2004-04-04 16:56 ` pinskia at gcc dot gnu dot org
2004-04-04 16:56 ` pinskia at gcc dot gnu dot org
2004-05-15 23:23 ` [Bug tree-optimization/14846] " kazu at cs dot umass dot edu
2004-05-24 22:32 ` pinskia at gcc dot gnu dot org
2005-04-21  0:39 ` cvs-commit at gcc dot gnu dot org
2005-04-21  0:40 ` kazu at cs dot umass dot edu

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