[PATCH] Optimize "a || b" into "(a | b) != 0"

Jan Hubicka jh@suse.cz
Sat May 18 07:57:00 GMT 2002


> 
> Hi Jan,
> > one of problem I see whit this idea is that it may result into expensive
> > expression when chained (imagine long sequence of a || b || c || d || e || f).
> 
> As I've mentioned earlier, this transformation is only applied once we've
> already committed to evaluating the left and right sides.  So in the
> example, above CVS mainline would generate.
> 
> 	t1 = (a != 0);
> 	t2 = (b != 0);
> 	t3 = (c != 0);
> 	t4 = (d != 0);
> 	t5 = (e != 0);
> 	t6 = (f != 0);
> 	return t1 | t2 | t3 | t4 | t5 | t6;

Hmm, this is interesting.  How long is GCC doing this transfromation?
2.95.3 certainly not at least in my simple testcase.

Honza



More information about the Gcc-patches mailing list