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]
Other format: [Raw text]

Re: copy to mode reg help needed


At 1:56 PM +0300 12/18/01, Dmitry wrote:

>Fellows,
>
>I got a problem:
>I define shift operations like:
>------------------------------------------------------------
>(define_expand "ashlqi3"
>  [(set (match_operand:QI 0 "nonimmediate_operand"       "=rm")
>        (ashift:QI (match_operand:QI 1 "nonimmediate_operand" "%0")


	FIRST PROBLEM:	  ashift is not commutative!  Get rid of the '%' in the constraints!

>                   (match_operand:QI 2 "general_operand"  "rmi")))]
>  ""
>  "{
>        if(!register_operand(operand0, QImode) && is_shift_better_in_reg(operands))
>        {
>                operands[0] = copy_to_mode_reg(QImode,operand0);
>                operands[1] = copy_to_mode_reg(QImode,operand1);
>                emit_insn (gen_ashlqi3fnl(operands[0], operands[1], operands[2]));
>                DONE;
>        }
>}")

	SECOND (POTENTIAL?) PROBLEM:  Avoid using operand0,... operandN in patterns.  I don't
	think you can depend on these names being defined and in fact at least at one point in time
	various insn-* transformers defined macros for the operands array.  You should consistently
	refer to operands in patterns via the operands[N] notation.

> 
> .......
>-----------------------------------------------------
>so, If source code is like:
>extern char d;
>void setd()
>{
>	d <<= 5;
>}
>
>the compiler still uses d as a memory reference:
>RTL dump is the following:
>/****************
>(insn 12 23 14 (set (mem/f:QI (symbol_ref:HI ("d")) 1)
>        (ashift:QI (mem/f:QI (symbol_ref:HI ("d")) 1)
>            (const_int 5 [0x5]))) 154 {*ashlqi3} (nil)
>    (nil))
>*****************/


	I'd look at your is_shift_is_better_in_reg() function to see that it is evaluating
	to true..
-- 
------------------------------------------------------------------------

		    Quality Software Management
		http://home.earthlink.net/~qsmgmt
			apl@alum.mit.edu
			(978)287-0435 Voice
			(978)808-6836 Cell
			(978)287-0436 Fax

	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]