[PATCH] Fix PR23109

Richard Guenther rguenther@suse.de
Fri Jul 29 09:00:00 GMT 2005


On Thu, 28 Jul 2005, Richard Henderson wrote:

> On Thu, Jul 28, 2005 at 05:04:33PM +0200, Richard Guenther wrote:
> > 	* tree-ssa-loop-im.c (determine_invariantness_stmt): Honour
> > 	trapping math during hoisting 1/d.
> 
> This is ok.
> 
> > 	* tree-ssa-math-opts.c (gate_cse_reciprocals): Likewise.
> 
> I don't like this one.  It prevents
> 
> 	b = foo;
> 	z = a/b + c/b;
> 
> from being converted, even though everything is in the same basic block.

But

  z = a/b + c/b;

traps two times, while

  d = 1/b;
  z = a*d + b*d;

traps only one time.  Is this a valid transformation then?  I.e.
one could count the number of traps with a signal handler.  Also
I believe the C standard says that at the point of the trap results
of previous sequence points are comitted, so

  global = x;
  z = a/b + c/b;

to

  d = 1/b;
  global = x;
  z = a*d + c*d;

would be invalid, as at the trap point, the store to global is not
observable.  So we'd need to do even stricter checks?

I'll commit the loop-im change later today.

Thanks,
Richard.



More information about the Gcc-patches mailing list