[PATCH][RTL-ifcvt] PR rtl-optimization/68841: Make sure one basic block doesn't clobber CC reg usage of the other

Kyrill Tkachov kyrylo.tkachov@foss.arm.com
Mon Jan 11 11:10:00 GMT 2016


Hi Bernd,

On 08/01/16 13:22, Bernd Schmidt wrote:
> On 01/08/2016 02:11 PM, Kyrill Tkachov wrote:
>> How's this?
>
> Hmm. Almost there, but...
>
>> -  if (then_bb && else_bb && !a_simple && !b_simple
>> -      && (!bbs_ok_for_cmove_arith (then_bb, else_bb)
>> -      || !bbs_ok_for_cmove_arith (else_bb, then_bb)))
>> +  rtx orig_x = x;
>> +  if (then_bb && else_bb)
>> +    {
>> +      orig_x = SET_DEST (single_set (insn_a));
>> +      gcc_assert (rtx_equal_p (orig_x, SET_DEST (single_set (insn_b))));
>> +    }
>> +
>> +  if (then_bb && else_bb
>> +      && (!bbs_ok_for_cmove_arith (then_bb, else_bb, orig_x)
>> +      || !bbs_ok_for_cmove_arith (else_bb, then_bb, orig_x)))
>>      return FALSE;
>
> This can be condensed to a single if statement (not repeating the then_bb && else_bb test), and orig_x can then be declared locally inside it.
>
> The remaining question is whether it's safe to call single_set in this way. I thought it was only guaranteed to be safe if then_simple and else_simple. I had assumed that orig_x was available in this function but I now see that it's 
> actually part of noce_process_if_block. I think it might be best to extend the if_info structure to also have an orig_x field. With that, I think we can even skip this particular assert (keeping the one in bbs_ok_for_cmove_arith however).
>

Ok, this works too. Here is a version that adds orig_x to the if_info struct and passes it down
to bbs_ok_for_cmove_arith.

This passes bootstrap and test on arm, aarch64, x86_64.

Thanks,
Kyrill

2016-01-11  Bernd Schmidt  <bschmidt@redhat.com>
             Kyrylo Tkachov  <kyrylo.tkachov@arm.com>

     PR rtl-optimization/68841
     * ifcvt.c (struct noce_if_info): Add orig_x field.
     (bbs_ok_for_cmove_arith): Add to_rename parameter.
     Don't record conflicts on to_rename if it's present.
     Allow memory destinations in sets.
     (noce_try_cmove_arith): Call bbs_ok_for_cmove_arith even on simple
     blocks, passing orig_x to the checks.
     (noce_process_if_block): Set if_info->orig_x appropriately.

2016-01-11  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>

     PR rtl-optimization/68841
     * gcc.dg/pr68841.c: New test.
     * gcc.c-torture/execute/pr68841.c: New test.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: ifcvt-tmp.patch
Type: text/x-patch
Size: 4843 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20160111/13aae001/attachment.bin>


More information about the Gcc-patches mailing list