public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/91540] missed value-replacement in phiopt
       [not found] <bug-91540-4@http.gcc.gnu.org/bugzilla/>
@ 2021-05-24  6:20 ` pinskia at gcc dot gnu.org
  2021-06-15  0:34 ` pinskia at gcc dot gnu.org
  2021-06-15  0:36 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-05-24  6:20 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91540

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Currently on the trunk we get:
        andl    %edi, %esi
        movl    $43, %eax
        movzbl  %sil, %esi
        subl    %esi, %eax

Which is close.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug tree-optimization/91540] missed value-replacement in phiopt
       [not found] <bug-91540-4@http.gcc.gnu.org/bugzilla/>
  2021-05-24  6:20 ` [Bug tree-optimization/91540] missed value-replacement in phiopt pinskia at gcc dot gnu.org
@ 2021-06-15  0:34 ` pinskia at gcc dot gnu.org
  2021-06-15  0:36 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-06-15  0:34 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91540

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
On the trunk we get:
  _5 = cond1_2(D) & cond2_3(D);
  _6 = (int) _5;
  _7 = 43 - _6;

If we replace the minus with xor, we would get what clang gives.
I think we do this with or though.

I looked into a slightly different case:
int Test(bool cond1, bool cond2)
{
    if (cond1)
    {
        if (cond2)
        {
            return 43;
        }
    }
    return 42;
}


int Test1(bool cond1, bool cond2)
{
    int t = 0;
    if (cond1)
    {
        if (cond2)
        {
            t = 1;
        }
    }
    return 42 + t;
}
int Test0(bool cond1, bool cond2)
{
    int t = 0;
    if (cond1)
    {
        if (cond2)
        {
            t = 1;
        }
    }
    return 42 + t;
}
int Test2(bool cond1, bool cond2)
{
    int t = cond1 & cond2;
    return 42 + t;
}
int Test3(bool cond1, bool cond2)
{
    int t = (cond1 & cond2);
    return 42 | t;
}

---- CUT ----
GCC produces the decent code for all of the Tests here while clang produces
produces decent for Test2 and Test3.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug tree-optimization/91540] missed value-replacement in phiopt
       [not found] <bug-91540-4@http.gcc.gnu.org/bugzilla/>
  2021-05-24  6:20 ` [Bug tree-optimization/91540] missed value-replacement in phiopt pinskia at gcc dot gnu.org
  2021-06-15  0:34 ` pinskia at gcc dot gnu.org
@ 2021-06-15  0:36 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-06-15  0:36 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91540

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
In summary, clang is trying to produce xor always for similar value reductions
(or still branches) while GCC produce plus and minus; though producing xor or
ior might lead to better code in general.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-06-15  0:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-91540-4@http.gcc.gnu.org/bugzilla/>
2021-05-24  6:20 ` [Bug tree-optimization/91540] missed value-replacement in phiopt pinskia at gcc dot gnu.org
2021-06-15  0:34 ` pinskia at gcc dot gnu.org
2021-06-15  0:36 ` pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).