Fix handling of call clobbering readonly-result

Richard Earnshaw rearnsha@arm.com
Thu May 8 17:11:00 GMT 2003


This is just a working hypothesis at present as to what is going wrong.

The fundamental failure is coming from an incorrect cse'ing of the calls 
to test3.

We then have

	x <- 80.0
	...
	result = call test3(x)
	if (result == 0)
	   abort();
	...
	x <- 100.0
	...
	resultb = call test3(x)
	if (resultb != 0)
	  abort ();

test3 is being marked as const (it is), but cse may only treat the results 
of calls to that function as being equivalent if the arguments (if any) 
are the same; in this case they are not, but cse is doing exactly that, 
and reducing the above to:

	x <- 80.0
	...
	result = call test3(x)
	if (result == 0)
	   abort();
	...
	x <- 100.0
	...
	resultb = call test3(x)
	if (result != 0) 	// Note, incorrect cse
	  abort();

Which of course, then collapses (since we know that result != 0) to 

	x <- 80.0
	...
	result = call test3(x)
	if (result == 0)
	   abort();
	...
	x <- 100.0
	...
	resultb = call test3(x)
	abort ();

Unfortunately, I don't know enough about CSE to begin to fix this :-(

R.



More information about the Gcc-patches mailing list