Bug 68026 - [6 Regression] Regression in GCC-6.0.0's optimizer
Summary: [6 Regression] Regression in GCC-6.0.0's optimizer
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 6.0
: P3 normal
Target Milestone: 6.0
Assignee: Richard Biener
URL:
Keywords: missed-optimization
Depends on:
Blocks:
 
Reported: 2015-10-20 03:00 UTC by Ishiura Lab Compiler Team
Modified: 2015-10-21 07:57 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2015-10-20 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ishiura Lab Compiler Team 2015-10-20 03:00:06 UTC
We compiled a program (A.c) by GCC-5.1.0 and GCC-6.0.0 with -O3 option.
GCC-5.1.0 performed better optimization than GCC-6.0.0.

(A.c)
int main (void)
{
	volatile int x1 = 1;
	volatile int x2 = 1;
	int x3 = 2;
	int t = 1;

	t = 3<=(x2|1|x3|x1-1U);

	if (t == 1) {} 
	else { __builtin_abort(); }

    return 0;
}

+--------------------------------------+--------------------------------------+
|  gcc-5.1.0.s (gcc-5.1.0 A.c -O3 -S)  |  gcc-6.0.0.s (gcc-6.0.0 A.c -O3 -S)  |
+--------------------------------------+--------------------------------------+
|main:                                 |main:                                 |
|.LFB0:                                |.LFB0:                                |
|        .cfi_startproc                |        .cfi_startproc                |
|        movl    $1, -8(%rsp)          |        subq    $24, %rsp             |
|        movl    $1, -4(%rsp)          |        .cfi_def_cfa_offset 32        |
|        movl    -4(%rsp), %eax        |        movl    $1, 8(%rsp)           |
|        movl    -8(%rsp), %eax        |        movl    $1, 12(%rsp)          |
|                                      |        movl    12(%rsp), %eax        |
|                                      |        movl    8(%rsp), %edx         |
|                                      |        orl     $3, %eax              |
|                                      |        movl    %eax, %ecx            |
|                                      |        leal    -1(%rdx), %eax        |
|                                      |        orl     %ecx, %eax            |
|                                      |        cmpl    $2, %eax              |
|                                      |        jbe     .L5                   |
|        xorl    %eax, %eax            |        xorl    %eax, %eax            |
|                                      |        addq    $24, %rsp             |
|                                      |        .cfi_remember_state           |
|                                      |        .cfi_def_cfa_offset 8         |
|        ret                           |        ret                           |
|                                      |.L5:                                  |
|                                      |        .cfi_restore_state            |
|                                      |        call    abort                 |
|        .cfi_endproc                  |        .cfi_endproc                  |
|.LFE0:                                |.LFE0:                                |
|        .size   main, .-main          |        .size   main, .-main          |
|        .section        .text.unlikely|        .ident  "GCC: (GNU) 6.0.0  ...|
|.LCOLDE0:                             |                                      |
|        .section        .text.startup |                                      |
|.LHOTE0:                              |                                      |
|        .ident  "GCC: (Ubuntu 5.1.0...|                                      |
|        .section        .note.GNU-s...|        .section        .note.GNU-s...|
+--------------------------------------+--------------------------------------+

Using built-in specs.
COLLECT_GCC=gcc-5
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/5/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 5.1.0-0ubuntu11~14.04.1' --with-bugurl=file:///usr/share/doc/gcc-5/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-5 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=c++98 --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-5-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-5-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-5-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 5.1.0 (Ubuntu 5.1.0-0ubuntu11~14.04.1) 

Using built-in specs.
COLLECT_GCC=gcc-6.0
COLLECT_LTO_WRAPPER=/home/iwatsuji/opt/gcc-6.0/libexec/gcc/x86_64-pc-linux-gnu/6.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc/configure --prefix=/home/iwatsuji/opt/gcc-6.0 --program-suffix=-6.0 --disable-multilib --enable-languages=c
Thread model: posix
gcc version 6.0.0 20151014 (experimental) (GCC)
Comment 1 Andrew Pinski 2015-10-20 03:08:04 UTC
	t = 3<=(x2|1|x3|x1-1U);
Doing the non-volatile sub:
t = 3 <= (x2 | 1 | 2 | (x1 - 1u))
...

t = 3 <= (x2 | 3 | (x1 - 1u))
or:
t = 3 <= 3 | x2 | (x1 - 1u)
Which is:

t = true, x1, x2.

Only if re-association happens with casts thrown in too which might be the  case of the  regression.
Comment 2 Marek Polacek 2015-10-20 09:06:23 UTC
Started with r222085.
Comment 3 Richard Biener 2015-10-20 10:13:19 UTC
Mine.
Comment 4 Richard Biener 2015-10-21 07:57:10 UTC
Fixed.
Comment 5 Richard Biener 2015-10-21 07:57:26 UTC
Author: rguenth
Date: Wed Oct 21 07:56:54 2015
New Revision: 229117

URL: https://gcc.gnu.org/viewcvs?rev=229117&root=gcc&view=rev
Log:
2015-10-21  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/68026
	* tree-ssa-ccp.c (get_value_for_expr): Zero-extend mask for
	unsigned VARYING values.

	* gcc.dg/tree-ssa/ssa-ccp-39.c: New testcase.

Added:
    trunk/gcc/testsuite/gcc.dg/tree-ssa/ssa-ccp-39.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-ssa-ccp.c