This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [ColdFire 22/63] Remove redundant PIC handling
Jeffrey Law <law@redhat.com> writes:
> On Wed, 2007-01-10 at 11:20 +0000, Richard Sandiford wrote:
>> The comment for cmpsi claims that it too needs to handle illegitimate
>> constant operands, in much the same way as movsi does. This may have
>> been true in the old days, but I don't think it is now. This patch
>> removes the comment and associated code. Note that the comment above
>> movsi doesn't need any adjusting; it doesn't refer to cmpsi.
>>
>> The patch also adds a PIC testcase that failed at one stage during
>> the original development process.
>>
>> Richard
>>
>>
>> gcc/
>> * config/m68k/m68k.md (cmpsi): Remove outdated flag_pic handling.
>>
>> gcc/testsuite/
>> 200x-xx-xx Nathan Sidwell <nathan@codesourcery.com>
>>
>> * gcc.dg/m68k-pic-1.c: New.
> I don't recall specifically (it's only been 15+ years) why we need to
> intercept cmpsi,
;)
> but it was certainly necessary. I'd like to see some explanation why
> you think it's no longer necessary before removing that code.
These days we enforce the predicates of cmpsi, like we do for other
optabs. The pattern is:
---------------------------------------------------------------------------
(define_expand "cmpsi"
[(set (cc0)
(compare (match_operand:SI 0 "nonimmediate_operand" "")
(match_operand:SI 1 "general_operand" "")))]
---------------------------------------------------------------------------
so we should only see nonimmediate_operands and general_operands
in the expander. E.g., emit_cmp_and_jump_insn_1 says:
---------------------------------------------------------------------------
/* Handle compares for which there is a directly suitable insn. */
icode = (int) cmp_optab->handlers[(int) wider_mode].insn_code;
if (icode != CODE_FOR_nothing)
{
x = prepare_operand (icode, x, 0, mode, wider_mode, unsignedp);
y = prepare_operand (icode, y, 1, mode, wider_mode, unsignedp);
emit_insn (GEN_FCN (icode) (x, y));
if (label)
emit_jump_insn (bcc_gen_fctn[(int) comparison] (label));
return;
}
---------------------------------------------------------------------------
where prepare_operand forces everything that doesn't match the predicate
into a register:
---------------------------------------------------------------------------
if (!insn_data[icode].operand[opnum].predicate
(x, insn_data[icode].operand[opnum].mode))
{
if (no_new_pseudos)
return NULL_RTX;
x = copy_to_mode_reg (insn_data[icode].operand[opnum].mode, x);
}
---------------------------------------------------------------------------
This copy_to_mode_reg will indirectly call the move expanders to
legitimize illegitimate operands. (And symbolic constants _are_
illegitimate operands for flag_pic && !TARGET_PCREL because of
LEGITIMATE_PIC_OPERAND_P.)
gen_cond_trap does a similar thing to emit_cmp_and_jump_insn_1.
Richard