public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/64322] New: More optimize opportunity for constant folding
@ 2014-12-15 23:01 ishiura-compiler at ml dot kwansei.ac.jp
  2014-12-16  0:41 ` [Bug tree-optimization/64322] " jakub at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: ishiura-compiler at ml dot kwansei.ac.jp @ 2014-12-15 23:01 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 64322
           Summary: More optimize opportunity for constant folding
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ishiura-compiler at ml dot kwansei.ac.jp

The two programs (A.c) and (B.c) only differ by one line
(marked by "// <---HERE"), where (B.c) change 0x100000000L to 0L.

Resulting codes by "x86_64-unknown-linux-gnu-gcc-5.0.0 -Os -S"
are different;
the code (A.s) for (A.c) is less optimized than (B.s) for (B.c).
Note that variable c is not referenced at all in this program.

(A.c)
int main (void)
{
          long a = -1L;
 volatile long b =  0L;
 volatile long c = 0x100000000L;      // <---HERE
 a = (1+b >> 63 << 1) / 0x100000000L;

 if (a == 0L);
 else __builtin_abort();

 return 0;
}

(B.c)
int main (void)
{
          long a = -1L;
 volatile long b =  0L;
 volatile long c =  0L;               // <---HERE
 a = (1+b >> 63 << 1) / 0x100000000L;

 if (a == 0L);
 else __builtin_abort();

 return 0;
}

+-----------------------------+-----------------------------+
|(A.s)                        |(B.s)                        |
+-----------------------------+-----------------------------+
|main:                        |main:                        |
|.LFB0:                       |.LFB0:                       |
|  .cfi_startproc             |  .cfi_startproc             |
|  subq  $24, %rsp            |  movq  $0, -24(%rsp)        |
|  .cfi_def_cfa_offset 32     |  movq  $0, -16(%rsp)        |
|  movabsq  $4294967296, %rcx |  movq  -24(%rsp), %rax      |
|  movq  $0, (%rsp)           |                             |
|  movq  %rcx, 8(%rsp)        |                             |
|  movq  (%rsp), %rax         |                             |
|  incq  %rax                 |                             |
|  sarq  $63, %rax            |                             |
|  addq  %rax, %rax           |                             |
|  cqto                       |                             |
|  idivq  %rcx                |                             |
|  testq  %rax, %rax          |                             |
|  je  .L2                    |                             |
|  call  abort                |                             |
|.L2:                         |                             |
|  xorl  %eax, %eax           |  xorl  %eax, %eax           |
|  addq  $24, %rsp            |                             |
|  .cfi_def_cfa_offset 8      |                             |
|  ret                        |  ret                        |
|  .cfi_endproc               |  .cfi_endproc               |
|.LHOTE0:                     |.LHOTE0:                     |
+-----------------------------+-----------------------------+

$ x86_64-unknown-linux-gnu-gcc-5.0.0 -v
Using built-in specs.
COLLECT_GCC=x86_64-unknown-linux-gnu-gcc-5.0.0
COLLECT_LTO_WRAPPER=/usr/local/x86_64-tools/gcc-5.0.0/libexec/gcc/x86_64-unknown-linux-gnu/5.0.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /home/hassy/gcc/configure
--prefix=/usr/local/x86_64-tools/gcc-5.0.0/
--with-gmp=/usr/local/gmp-5.1.1/ --with-mpfr=/usr/local/mpfr-3.1.2/
--with-mpc=/usr/local/mpc-1.0.1/ --disable-multilib --disable-nls
--enable-languages=c
Thread model: posix
gcc version 5.0.0 20141215 (experimental) (GCC)


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

end of thread, other threads:[~2021-08-19 19:26 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-15 23:01 [Bug tree-optimization/64322] New: More optimize opportunity for constant folding ishiura-compiler at ml dot kwansei.ac.jp
2014-12-16  0:41 ` [Bug tree-optimization/64322] " jakub at gcc dot gnu.org
2014-12-16 10:11 ` rguenth at gcc dot gnu.org
2014-12-16 10:26 ` jakub at gcc dot gnu.org
2014-12-16 11:50 ` rguenth at gcc dot gnu.org
2014-12-17  9:29 ` jakub at gcc dot gnu.org
2014-12-17 12:36 ` jakub at gcc dot gnu.org
2014-12-17 14:25 ` rguenther at suse dot de
2021-08-19 19:26 ` 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).