This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

problem with expand_fix() in optabs.c with RS6000


Found an amusing bug on the PPC backend that probably infects
all load/store architectures.

Consider the following simple code fragment.


	void f (volatile unsigned int *p, double *d)
	{
		*p = (unsigned int) *d;

	}

This results in code that does the correct conversion to
get 32 bits of significand and store it into the memory
location addressed by p.

BUT....

Then it does an extra load thru the pointer and a
store again.

This is really bad if p really points to a device register.
[Note: I know that MOST real operating systems would NEVER use
double precision in a device register, but I know of embedded
controller applications that want to do things like this!

The cause of this bug is code in expand_fix() that tries to
place a REG_NOTES at the "join" between the two conditional
expansions for the fix operation.

	  if (mov_optab->handlers[(int) GET_MODE (to)].insn_code
	      != CODE_FOR_nothing)
	    {
	      /* Make a place for a REG_NOTE and add it.  */
	      insn = emit_move_insn (to, to);
	      REG_NOTES (insn) = gen_rtx (EXPR_LIST, REG_EQUAL,
					  gen_rtx (UNSIGNED_FIX, GET_MODE (to),
						   copy_rtx (from)),
					  REG_NOTES (insn));
	    }

In gcc 2.8, someone added the predicate to insure that there
was an instruction available for the mode (to prevent REALLY silly
things from happening), but since on the RS6000, memory-to-memory
moves are expanded into two instructions which aren't eliminated
by the move-to-self elimination code.

So, we need a mechanism that allows us to emit instructions
that won't be eliminated too soon, but that won't end up with an overhead
(and perhaps with unfortunate and undesired side-effects).

And, I wonder how many other places we have similar hacks that
get in the way of device-driver semantics?

-- Al Lehotsky


	2
------------------------------------------------------------------------

		    Quality Software Management
		http://www.tiac.net/users/lehotsky
			lehotsky@tiac.net
			(978)287-0435 Voice
			(978)287-0436 Fax/Data

	Software Process Improvement and Management Consulting
	     Language Design and Compiler Implementation


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]