public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/55869] New: different bit shift/or optimization.
@ 2013-01-03 20:13 pluto at agmk dot net
  2013-01-03 20:25 ` [Bug tree-optimization/55869] " pinskia at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: pluto at agmk dot net @ 2013-01-03 20:13 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55869

             Bug #: 55869
           Summary: different bit shift/or optimization.
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: pluto@agmk.net


here're equvialent functions:

$ cat u.cpp
unsigned long long convert_1( bool flag )
{
        return (unsigned long long)(flag ? 1ull : 0ull) << 57;
}
unsigned long long convert_2( bool flag )
{
        return (unsigned long long)flag << 57;
}

current 4.7/4.8 gcc emits following different machine code:

_Z9convert_1b:

        testb   %dil, %dil      # 29    *cmpqi_ccno_1/1 [length = 3]
        movl    $0, %edx        # 32    *movdi_internal_rex64/1 [length = 5]
        movabsq $144115188075855872, %rax       # 28    *movdi_internal_rex64/3
[length = 10]
        cmove   %rdx, %rax      # 31    *movdicc_noc/1  [length = 4]
        ret     # 39    simple_return_internal  [length = 1]

_Z9convert_2b:
        movq    %rdi, %rax      # 19    *movdi_internal_rex64/2 [length = 3]
        salq    $57, %rax       # 8     *ashldi3_1/1    [length = 4]
        ret     # 27    simple_return_internal  [length = 1]


while clang/llvm emits equivalent machine code for both functions:

_Z9convert_1b:                          # @_Z9convert_1b
        movzbl  %dil, %eax
        shlq    $57, %rax
        ret

_Z9convert_2b:                          # @_Z9convert_2b
        movzbl  %dil, %eax
        shlq    $57, %rax
        ret


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

* [Bug tree-optimization/55869] different bit shift/or optimization.
  2013-01-03 20:13 [Bug tree-optimization/55869] New: different bit shift/or optimization pluto at agmk dot net
@ 2013-01-03 20:25 ` pinskia at gcc dot gnu.org
  2013-01-04 10:37 ` rguenth at gcc dot gnu.org
  2021-05-24  7:12 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2013-01-03 20:25 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55869

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> 2013-01-03 20:25:27 UTC ---
The question I think comes down to this is shifting faster than testb/cmove ?


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

* [Bug tree-optimization/55869] different bit shift/or optimization.
  2013-01-03 20:13 [Bug tree-optimization/55869] New: different bit shift/or optimization pluto at agmk dot net
  2013-01-03 20:25 ` [Bug tree-optimization/55869] " pinskia at gcc dot gnu.org
@ 2013-01-04 10:37 ` rguenth at gcc dot gnu.org
  2021-05-24  7:12 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu.org @ 2013-01-04 10:37 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55869

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |missed-optimization
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2013-01-04
     Ever Confirmed|0                           |1

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> 2013-01-04 10:36:52 UTC ---
In CCP we optimize this to

  <bb 2>:
  if (flag_2(D) != 0)
    goto <bb 4>;
  else
    goto <bb 3>;

  <bb 3>:

  <bb 4>:
  # iftmp.0_1 = PHI <144115188075855872(2), 0(3)>
  return iftmp.0_1;

before phiopt can apply valueization of flag ? 1 : 0.


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

* [Bug tree-optimization/55869] different bit shift/or optimization.
  2013-01-03 20:13 [Bug tree-optimization/55869] New: different bit shift/or optimization pluto at agmk dot net
  2013-01-03 20:25 ` [Bug tree-optimization/55869] " pinskia at gcc dot gnu.org
  2013-01-04 10:37 ` rguenth at gcc dot gnu.org
@ 2021-05-24  7:12 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-05-24  7:12 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |DUPLICATE
             Status|NEW                         |RESOLVED

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This is actually already fixed for GCC 11 by the patch which fixed PR 97690 and
is really a dup of it.

*** This bug has been marked as a duplicate of bug 97690 ***

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

end of thread, other threads:[~2021-05-24  7:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-03 20:13 [Bug tree-optimization/55869] New: different bit shift/or optimization pluto at agmk dot net
2013-01-03 20:25 ` [Bug tree-optimization/55869] " pinskia at gcc dot gnu.org
2013-01-04 10:37 ` rguenth at gcc dot gnu.org
2021-05-24  7:12 ` 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).