This is the mail archive of the gcc-patches@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: [PATCH] Improve folding of bitwise ops feeding conditionals for single bit types


On Thu, Jun 20, 2013 at 2:52 PM, Jeff Law <law@redhat.com> wrote:
> On 06/20/2013 04:49 AM, Andreas Schwab wrote:
>>
>> Jeff Law <law@redhat.com> writes:
>>
>>> +/* { dg-final { scan-tree-dump-times "Replaced" 8 "forwprop1"} } */
>>
>>
>> $ grep -c Replaced forwprop-28.c.022t.forwprop1
>> 16
>>
>> ;; Function test (test, funcdef_no=0, decl_uid=1388, symbol_order=0)
>>
>>    Replaced 'rotate_7 == 0' with '_6 == 0'
>>    Replaced '_6 == 0' with 'code_5(D) != 22'
>
> Target?
>
> Give me enough information and I'll gladly take a look.  Give me junk and
> I'll ignore.

I see this now as well with match-and-simplify and a pending merge piece
(soon to be committed, with testcase adjustment).  We have a conflicting
transform, so if you for example consider

void
test_4 (int code)
{
  char *temp = frob ();
  int rotate = (code == 22);
  if (temp == 0 || !rotate)
    oof ();
}

then the conflicting transform is to simplify !(code == 22) to code != 22.
If that happens first then the if () no longer is of X || !Y form but we
see X || Y and thus your transform no longer applies (the transform
meanwhile moved to match.pd - I am now moving !(code == 22) to
code != 22 as well).

Btw, I see better generated code on x86 when doing !(code == 22)
-> code != 22 rather than transforming temp == 0 || !rotate to
rotate <= (temp == 0).  With your transform I see

        movl    %edi, %ebx
        call    frob
        cmpl    $22, %ebx
        sete    %dl
        testq   %rax, %rax
        sete    %al
        cmpb    %al, %dl
        jbe     .L17

while with the code != 22 one I see

        movl    %edi, %ebx
        call    frob
        testq   %rax, %rax
        je      .L28
        cmpl    $22, %ebx
        jne     .L28

So I wonder if it is beneficial at all ...

Thanks,
Richard.

> jeff


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