Bug 61583 - [4.9/4.10 regression] stage2 and stage3 compare failure due to value range loss
Summary: [4.9/4.10 regression] stage2 and stage3 compare failure due to value range loss
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: bootstrap (show other bugs)
Version: 4.9.1
: P3 normal
Target Milestone: 4.9.1
Assignee: Alan Modra
URL:
Keywords: build
Depends on:
Blocks:
 
Reported: 2014-06-23 05:19 UTC by Alan Modra
Modified: 2014-06-23 17:56 UTC (History)
3 users (show)

See Also:
Host:
Target: powerpc64-linux, x64_64-linux
Build:
Known to work:
Known to fail:
Last reconfirmed: 2014-06-23 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alan Modra 2014-06-23 05:19:40 UTC
Seen first on ibm-4.9 branch with powerpc64, but also occurs on 4.9 branch with both powerpc64 and x86_64.  x86_64 configured with --enable-threads=posix --disable-shared --disable-libmudflap --disable-libssp --disable-lto --disable-libgomp --without-ppl --without-cloog --disable-checking --enable-languages=c,c++

results for revision 211867 x86_64 as follows, powerpc64 doesn't hit the builtins.o fail.  Note that --disable-checking seems necessary.

Bootstrap comparison failure!
gcc/tree-vect-stmts.o differs
gcc/builtins.o differs
gcc/tree-vect-loop.o differs

Disassembling tree-vect-stmts.o shows loop exit branches differ for
      for (j = 0; j < ncopies; ++j)
in vectorizable_mask_load_store.


ivopts details dump differences (- no debug, + debug):

@@ -16220,10 +19173,11 @@
 
 Analyzing # of iterations of loop 1
   exit condition [1, + , 1](no_overflow) < ncopies_19
-  bounds on difference of bases: 0 ... 2147483646
+  bounds on difference of bases: -2147483649 ... 2147483646
   result:
+    zero if ncopies_19 <= 0
     # of iterations (unsigned int) ncopies_19 + 4294967295, bounded by 2147483646
-  number of iterations (unsigned int) ncopies_19 + 4294967295
+  number of iterations (unsigned int) ncopies_19 + 4294967295; zero if ncopies_19 <= 0
 
 Induction variables:
 
@@ -16334,7 +19288,7 @@
   0    0       0       1
   1    0       0       1
   2    0       0       1
-  3    0       0       1
+  3    4       1       1
 
 Use 2:
   cand cost    compl.  depends on
@@ -16428,18 +19382,17 @@
   base 0
   step 1
 
-Replacing exit test: if (ncopies_19 > j_153)
 bool vectorizable_assignment(gimple, gimple_stmt_iterator*, gimple_statement_base**, slp_tree) (struct gimple_statement_base * stmt
 {
[snip]

So there's why the exit test changes, with no debug output the exit test is
if (ncopies_19 != j_153), with debug info you keep the original test.

A gdb session shows that ncopies_19 has NULL SSA_NAME_RANGE_INFO during ivopts with -g, but does have SSA_NAME_RANGE_INFO without -g, which agrees with the dump output above.
Comment 1 Alan Modra 2014-06-23 05:49:26 UTC
A bit more poking and I see that VR info is being added during the vrp1 pass by tree-vrp.c:remove_range_assertions, but not when -g.

Hmm, at a guess the root cause of the problem is that is_unreachable is being set to zero by debug statements.  Trying the following simple patch

Index: gcc/tree-vrp.c
===================================================================
--- gcc/tree-vrp.c	(revision 211398)
+++ gcc/tree-vrp.c	(working copy)
@@ -6661,8 +6661,9 @@ remove_range_assertions (void)
 	  }
 	else
 	  {
+	    if (!is_gimple_debug (gsi_stmt (si)))
+	      is_unreachable = 0;
 	    gsi_next (&si);
-	    is_unreachable = 0;
 	  }
       }
 }
Comment 2 Jakub Jelinek 2014-06-23 07:35:25 UTC
Preapproved with proper ChangeLog entry and if possible some testcase (with -fcompare-debug in dg-options).
Comment 3 Alan Modra 2014-06-23 15:09:03 UTC
Author: amodra
Date: Mon Jun 23 15:08:30 2014
New Revision: 211897

URL: https://gcc.gnu.org/viewcvs?rev=211897&root=gcc&view=rev
Log:
gcc/
	PR bootstrap/61583
	* tree-vrp.c (remove_range_assertions): Do not set is_unreachable
	to zero on debug statements.
gcc/testsuite/
	* gcc.dg/pr61583.c: New.


Added:
    trunk/gcc/testsuite/gcc.dg/pr61583.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-vrp.c
Comment 4 Alan Modra 2014-06-23 15:11:05 UTC
Author: amodra
Date: Mon Jun 23 15:10:32 2014
New Revision: 211898

URL: https://gcc.gnu.org/viewcvs?rev=211898&root=gcc&view=rev
Log:
gcc/
	PR bootstrap/61583
	* tree-vrp.c (remove_range_assertions): Do not set is_unreachable
	to zero on debug statements.
gcc/testsuite/
	* gcc.dg/pr61583.c: New.


Added:
    branches/gcc-4_9-branch/gcc/testsuite/gcc.dg/pr61583.c
Modified:
    branches/gcc-4_9-branch/gcc/ChangeLog
    branches/gcc-4_9-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_9-branch/gcc/tree-vrp.c
Comment 5 Alan Modra 2014-06-23 15:16:15 UTC
Fixed.  BTW, s/vectorizable_mask_load_store/vectorizable_assignment/ in the original description.
Comment 6 Peter Bergner 2014-06-23 17:56:21 UTC
Author: bergner
Date: Mon Jun 23 17:55:49 2014
New Revision: 211908

URL: https://gcc.gnu.org/viewcvs?rev=211908&root=gcc&view=rev
Log:
	Merge up to 211899.
	* REVISION: Update subversion id.

	Picks up fix for bug 61583.

Added:
    branches/ibm/gcc-4_9-branch/gcc/testsuite/g++.dg/cpp0x/constexpr-template7.C
      - copied unchanged from r211899, branches/gcc-4_9-branch/gcc/testsuite/g++.dg/cpp0x/constexpr-template7.C
    branches/ibm/gcc-4_9-branch/gcc/testsuite/g++.dg/cpp0x/ref-qual15.C
      - copied unchanged from r211899, branches/gcc-4_9-branch/gcc/testsuite/g++.dg/cpp0x/ref-qual15.C
    branches/ibm/gcc-4_9-branch/gcc/testsuite/g++.dg/cpp0x/variadic159.C
      - copied unchanged from r211899, branches/gcc-4_9-branch/gcc/testsuite/g++.dg/cpp0x/variadic159.C
    branches/ibm/gcc-4_9-branch/gcc/testsuite/g++.dg/debug/dwarf2/imported-decl-2.C
      - copied unchanged from r211899, branches/gcc-4_9-branch/gcc/testsuite/g++.dg/debug/dwarf2/imported-decl-2.C
    branches/ibm/gcc-4_9-branch/gcc/testsuite/g++.dg/ipa/pr61540.C
      - copied unchanged from r211899, branches/gcc-4_9-branch/gcc/testsuite/g++.dg/ipa/pr61540.C
    branches/ibm/gcc-4_9-branch/gcc/testsuite/g++.dg/template/local-fn1.C
      - copied unchanged from r211899, branches/gcc-4_9-branch/gcc/testsuite/g++.dg/template/local-fn1.C
    branches/ibm/gcc-4_9-branch/gcc/testsuite/gcc.dg/lto/pr61526_0.c
      - copied unchanged from r211899, branches/gcc-4_9-branch/gcc/testsuite/gcc.dg/lto/pr61526_0.c
    branches/ibm/gcc-4_9-branch/gcc/testsuite/gcc.dg/lto/pr61526_1.c
      - copied unchanged from r211899, branches/gcc-4_9-branch/gcc/testsuite/gcc.dg/lto/pr61526_1.c
    branches/ibm/gcc-4_9-branch/gcc/testsuite/gcc.dg/pr61583.c
      - copied unchanged from r211899, branches/gcc-4_9-branch/gcc/testsuite/gcc.dg/pr61583.c
    branches/ibm/gcc-4_9-branch/gcc/testsuite/gcc.target/aarch64/aapcs64/va_arg-13.c
      - copied unchanged from r211899, branches/gcc-4_9-branch/gcc/testsuite/gcc.target/aarch64/aapcs64/va_arg-13.c
    branches/ibm/gcc-4_9-branch/gcc/testsuite/gcc.target/aarch64/aapcs64/va_arg-14.c
      - copied unchanged from r211899, branches/gcc-4_9-branch/gcc/testsuite/gcc.target/aarch64/aapcs64/va_arg-14.c
    branches/ibm/gcc-4_9-branch/gcc/testsuite/gcc.target/aarch64/aapcs64/va_arg-15.c
      - copied unchanged from r211899, branches/gcc-4_9-branch/gcc/testsuite/gcc.target/aarch64/aapcs64/va_arg-15.c
    branches/ibm/gcc-4_9-branch/gcc/testsuite/gcc.target/i386/pr61423.c
      - copied unchanged from r211899, branches/gcc-4_9-branch/gcc/testsuite/gcc.target/i386/pr61423.c
    branches/ibm/gcc-4_9-branch/gcc/testsuite/gfortran.dg/cray_pointers_10.f90
      - copied unchanged from r211899, branches/gcc-4_9-branch/gcc/testsuite/gfortran.dg/cray_pointers_10.f90
Modified:
    branches/ibm/gcc-4_9-branch/   (props changed)
    branches/ibm/gcc-4_9-branch/gcc/ChangeLog
    branches/ibm/gcc-4_9-branch/gcc/ChangeLog.ibm
    branches/ibm/gcc-4_9-branch/gcc/DATESTAMP
    branches/ibm/gcc-4_9-branch/gcc/REVISION
    branches/ibm/gcc-4_9-branch/gcc/cgraph.c
    branches/ibm/gcc-4_9-branch/gcc/config.gcc
    branches/ibm/gcc-4_9-branch/gcc/config/aarch64/aarch64-simd.md
    branches/ibm/gcc-4_9-branch/gcc/config/aarch64/aarch64.c
    branches/ibm/gcc-4_9-branch/gcc/config/aarch64/aarch64.md
    branches/ibm/gcc-4_9-branch/gcc/config/arm/arm.c
    branches/ibm/gcc-4_9-branch/gcc/config/i386/i386.c
    branches/ibm/gcc-4_9-branch/gcc/config/i386/i386.md
    branches/ibm/gcc-4_9-branch/gcc/config/msp430/msp430.md
    branches/ibm/gcc-4_9-branch/gcc/cp/ChangeLog
    branches/ibm/gcc-4_9-branch/gcc/cp/call.c
    branches/ibm/gcc-4_9-branch/gcc/cp/class.c
    branches/ibm/gcc-4_9-branch/gcc/cp/pt.c
    branches/ibm/gcc-4_9-branch/gcc/fortran/ChangeLog
    branches/ibm/gcc-4_9-branch/gcc/fortran/trans-decl.c
    branches/ibm/gcc-4_9-branch/gcc/ipa-prop.c
    branches/ibm/gcc-4_9-branch/gcc/lra-constraints.c
    branches/ibm/gcc-4_9-branch/gcc/testsuite/ChangeLog
    branches/ibm/gcc-4_9-branch/gcc/testsuite/gcc.target/aarch64/aapcs64/type-def.h
    branches/ibm/gcc-4_9-branch/gcc/tree-vrp.c
    branches/ibm/gcc-4_9-branch/libjava/classpath/   (props changed)

Propchange: branches/ibm/gcc-4_9-branch/
            ('svn:mergeinfo' modified)

Propchange: branches/ibm/gcc-4_9-branch/
            ('svnmerge-integrated' modified)

Propchange: branches/ibm/gcc-4_9-branch/libjava/classpath/
            ('svn:mergeinfo' modified)