This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[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
- From: "kazu at cs dot umass dot edu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 4 Apr 2004 16:47:21 -0000
- Subject: [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
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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