[tree-ssa] PATCH to gimplify_boolean_expr

Daniel Berlin dberlin@dberlin.org
Mon Aug 25 19:15:00 GMT 2003


On Monday, August 25, 2003, at 2:18 PM, Jason Merrill wrote:

> While testing my patch to always evaluate complex expressions into 
> formal
> temps, I ran into a new failure on gcc.dg/tree-ssa/20030728-1.c 
> because the
> generated gimple code changed from
>
>   T1 = (foo == bar);
>   if (T1)
>     ...
>
> to
>
>   T1 = (foo == bar);   // formal temp
>   T2 = T1;             // variable temp
>   if (T2)
>     ...
>
> dom provided constant defs of T2 within the branches, but ccp replaced 
> uses
> of T2 with T1, so we didn't see them.
>
> One fix for this is to move the comparison directly into the condition,
> i.e.
>
> if (foo == bar)
>   T1 = true;
>   ...
>
> which seems to be roughly what the expander does.  This also 
> dramatically
> simplifies gimplify_boolean_expr; now we can just hand off to the code 
> in
> shortcut_cond_expr.

If you do this, it means we won't hoist the comparison out loops, 
because we don't hoist control statements (cause it's much trickier in 
our current representation)

IE before
int a = <blah1>
int b = <blah2>

for (i = 0; i < 50; i ++)
{
	T.1 = a == b
	if (T.1)
	{	
		...
	}
}

We'd transform this into:

int a = <blah1>
int b = <blah2>

T.1 = a == b;
for (i  = 0; i < 50; i++)
{
	if (T.1)
	{
		...
	}
}

If you make it into
if (a == b)

we won't hoist anything.



More information about the Gcc-patches mailing list