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: Unable to reload subreg


> > This should perform a double word addition (HImode on my target). 
> > Since I haven't defined an addhi3 instruction, gcc tries to 
> > solve this problem with addqi3, and uses (subreg:QI (reg:HI)) 
> > to access the low and high part of this double word value.
> > The problem I run into is that in my cross compiler seems 
> > not to be able to reload the destination (subreg:QI (reg:HI)) 
> > into a QImode register. This happens when I adjust the 
> > constraints to force the result into a register. When I allow 
> > the result in memory, no error occurs.
> 
> Try adding the -da option, and looking at the .greg output 
> file.  This will include info about the reloads generated for the 
> insn in question

I tried this, but the .greg file is almost empty. The only line it 
contains is: ;; Function main
 
> The problem here could be that you don't have enough registers. 
> If you modify the pattern to 
> use a matching constraint, which effecively turns it into a 2-operand 
> add, then I think you can get by with 5 registers.  This may 
> be enough to make it work.

I don't think that the problem is that there aren't enough registers.
Somehow it seems that gcc doesn't know how to reload a subreg:QI destination 
into a QImode register.

When I create an addhi3 pattern, in which I force the required reloads, it
works:

	rtx op0_low  = force_reg(QImode, gen_lowpart (QImode, operands[0]));
	rtx op1_low  = gen_lowpart (QImode, operands[1]);
	rtx op2_low  = gen_lowpart (QImode, operands[2]);
  	rtx op0_high = force_reg(QImode, gen_highpart (QImode, operands[0]));
	rtx op1_high = gen_highpart (QImode, operands[1]);
	rtx op2_high = gen_highpart (QImode, operands[2]);

	emit_insn( gen_addqi3_normal(op0_low, op1_low, op2_low) );
	emit_insn( gen_movqi( gen_lowpart(QImode, operands[0]), op0_low ) );

	emit_insn( gen_addqi3_carry(op0_high, op1_high, op2_high) );
	emit_insn( gen_movqi( gen_highpart(QImode, operands[0]), op0_high ) );
	DONE; 

But I think that reload should be able to do this automatically, and not
generate an error.

-
Rene Willemink


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