[Bug tree-optimization/59445] [4.9 Regression] ICE in add_old_iv_candidates, at tree-ssa-loop-ivopts.c:2541

2013-12-14 Thread dominiq at lps dot ens.fr
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59445

Dominique d'Humieres dominiq at lps dot ens.fr changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--- Comment #19 from Dominique d'Humieres dominiq at lps dot ens.fr ---
AFAICT this is fixed by revision 205959:

http://gcc.gnu.org/viewcvs/gcc?view=revisionsortby=daterevision=205959
Author:amker
Date:Fri Dec 13 11:36:22 2013 UTC (28 hours, 17 minutes ago)
Changed paths:8
Log Message:
PR tree-optimization/58296
PR tree-optimization/41488
* tree-scalar-evolution.c: Include necessary header files.
(simplify_peeled_chrec): New function.
(analyze_evolution_in_loop): New static variable.
Call simplify_peeled_chrec.
* tree-ssa-loop-ivopts.c (mark_bivs): Don't mark peeled IV as biv.
(add_old_iv_candidates): Don't add candidate for peeled IV.
* tree-affine.h (aff_combination_zero_p): New function.

PR tree-optimization/58296
PR tree-optimization/41488
* gcc.dg/tree-ssa/scev-7.c: New test.
* gcc.dg/pr41488.c: New test.
* g++.dg/pr59445.C: New test.

Closing as FIXED.


[Bug tree-optimization/59445] [4.9 Regression] ICE in add_old_iv_candidates, at tree-ssa-loop-ivopts.c:2541

2013-12-12 Thread dominiq at lps dot ens.fr
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59445

--- Comment #17 from Dominique d'Humieres dominiq at lps dot ens.fr ---
 I fixed the reported problem and posted new patch at 
 http://gcc.gnu.org/ml/gcc-patches/2013-12/msg01159.html
 Apology that I missed java in bootstrap for previous patch.  This version 
 passes bootstrap and test for c,c++,lto,fortran,java,go,objc,obj_c++ on 
 x86_64.  

Well, it has been a long time without libjava breaking bootstrap!

 I am not sure if the java case is covered by bootstrap, or other 
 applications.  
 If it's in other application, could anyone help verifying that the issue is 
 addressed on apple-darwin?

I have bootstrapped end regtested revision 205924 with the patch on
x86_64-apple-darwin13 without any problem.


[Bug tree-optimization/59445] [4.9 Regression] ICE in add_old_iv_candidates, at tree-ssa-loop-ivopts.c:2541

2013-12-12 Thread amker.cheng at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59445

--- Comment #18 from bin.cheng amker.cheng at gmail dot com ---
Hi Dominique d'Humieres,
Thanks for verifying it.


[Bug tree-optimization/59445] [4.9 Regression] ICE in add_old_iv_candidates, at tree-ssa-loop-ivopts.c:2541

2013-12-11 Thread amker.cheng at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59445

--- Comment #16 from bin.cheng amker.cheng at gmail dot com ---
I fixed the reported problem and posted new patch at
http://gcc.gnu.org/ml/gcc-patches/2013-12/msg01159.html
Apology that I missed java in bootstrap for previous patch.  This version
passes bootstrap and test for c,c++,lto,fortran,java,go,objc,obj_c++ on x86_64.
 I am not sure if the java case is covered by bootstrap, or other applications.
 If it's in other application, could anyone help verifying that the issue is
addressed on apple-darwin?

Thanks.


[Bug tree-optimization/59445] [4.9 Regression] ICE in add_old_iv_candidates, at tree-ssa-loop-ivopts.c:2541

2013-12-10 Thread rguenth at gcc dot gnu.org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59445

Richard Biener rguenth at gcc dot gnu.org changed:

   What|Removed |Added

   Priority|P3  |P1
   Target Milestone|--- |4.9.0


[Bug tree-optimization/59445] [4.9 Regression] ICE in add_old_iv_candidates, at tree-ssa-loop-ivopts.c:2541

2013-12-10 Thread dominiq at lps dot ens.fr
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59445

Dominique d'Humieres dominiq at lps dot ens.fr changed:

   What|Removed |Added

 CC||howarth at nitro dot med.uc.edu

--- Comment #1 from Dominique d'Humieres dominiq at lps dot ens.fr ---
*** Bug 59455 has been marked as a duplicate of this bug. ***


[Bug tree-optimization/59445] [4.9 Regression] ICE in add_old_iv_candidates, at tree-ssa-loop-ivopts.c:2541

2013-12-10 Thread hjl.tools at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59445

H.J. Lu hjl.tools at gmail dot com changed:

   What|Removed |Added

 Status|UNCONFIRMED |WAITING
   Last reconfirmed||2013-12-10
 Ever confirmed|0   |1

--- Comment #2 from H.J. Lu hjl.tools at gmail dot com ---
Please add -v to gcj to show what options are passed to jc1


[Bug tree-optimization/59445] [4.9 Regression] ICE in add_old_iv_candidates, at tree-ssa-loop-ivopts.c:2541

2013-12-10 Thread howarth at nitro dot med.uc.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59445

--- Comment #3 from Jack Howarth howarth at nitro dot med.uc.edu ---
/sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/./gcc/jc1
/var/tmp//ccSlyCZfjx -fhash-synchronization -fuse-divide-subroutine
-fcheck-references -fuse-boehm-gc -fnon-call-exceptions -fkeep-inline-functions
-fPIC -feliminate-unused-debug-symbols -quiet -dumpbase ccSlyCZfjx
-mmacosx-version-min=10.8.5 -m32 -mtune=generic -auxbase-strip
java/awt/.libs/image.o -g -O2 -Wno-deprecated -version -ffilelist-file
-ffloat-store -fomit-frame-pointer -fencoding=UTF-8 -fbootstrap-classes
-fsource-filename=/sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/x86_64-apple-darwin12.5.0/i386/libjava/classpath/lib/classes
-fno-common
-fbootclasspath=./:../../../../gcc-4.9-20131210/libjava/classpath/lib/
-faux-classpath ccSlyCZfjx.zip -MD_ -MT java/awt/image.lo -MF
java/awt/image.deps -o ccSlyCZfjx.s


[Bug tree-optimization/59445] [4.9 Regression] ICE in add_old_iv_candidates, at tree-ssa-loop-ivopts.c:2541

2013-12-10 Thread howarth at nitro dot med.uc.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59445

--- Comment #4 from Jack Howarth howarth at nitro dot med.uc.edu ---
(In reply to Jack Howarth from comment #3)
 /sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/./gcc/jc1
 /var/tmp//ccSlyCZfjx -fhash-synchronization -fuse-divide-subroutine
 -fcheck-references -fuse-boehm-gc -fnon-call-exceptions
 -fkeep-inline-functions -fPIC -feliminate-unused-debug-symbols -quiet
 -dumpbase ccSlyCZfjx -mmacosx-version-min=10.8.5 -m32 -mtune=generic
 -auxbase-strip java/awt/.libs/image.o -g -O2 -Wno-deprecated -version
 -ffilelist-file -ffloat-store -fomit-frame-pointer -fencoding=UTF-8
 -fbootstrap-classes
 -fsource-filename=/sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/x86_64-
 apple-darwin12.5.0/i386/libjava/classpath/lib/classes -fno-common
 -fbootclasspath=./:../../../../gcc-4.9-20131210/libjava/classpath/lib/
 -faux-classpath ccSlyCZfjx.zip -MD_ -MT java/awt/image.lo -MF
 java/awt/image.deps -o ccSlyCZfjx.s

opps, that actually was -mtune=core2 but -mtune=generic also segfaults jc1.


[Bug tree-optimization/59445] [4.9 Regression] ICE in add_old_iv_candidates, at tree-ssa-loop-ivopts.c:2541

2013-12-10 Thread hjl.tools at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59445

--- Comment #5 from H.J. Lu hjl.tools at gmail dot com ---
(In reply to Jack Howarth from comment #4)
 (In reply to Jack Howarth from comment #3)
  /sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/./gcc/jc1
  /var/tmp//ccSlyCZfjx -fhash-synchronization -fuse-divide-subroutine
  -fcheck-references -fuse-boehm-gc -fnon-call-exceptions
  -fkeep-inline-functions -fPIC -feliminate-unused-debug-symbols -quiet
  -dumpbase ccSlyCZfjx -mmacosx-version-min=10.8.5 -m32 -mtune=generic
  -auxbase-strip java/awt/.libs/image.o -g -O2 -Wno-deprecated -version
  -ffilelist-file -ffloat-store -fomit-frame-pointer -fencoding=UTF-8
  -fbootstrap-classes
  -fsource-filename=/sw/src/fink.build/gcc49-4.9.0-1000/darwin_objdir/x86_64-
  apple-darwin12.5.0/i386/libjava/classpath/lib/classes -fno-common
  -fbootclasspath=./:../../../../gcc-4.9-20131210/libjava/classpath/lib/
  -faux-classpath ccSlyCZfjx.zip -MD_ -MT java/awt/image.lo -MF
  java/awt/image.deps -o ccSlyCZfjx.s
 
 opps, that actually was -mtune=core2 but -mtune=generic also segfaults jc1.

What is the equivalent of -march=?


[Bug tree-optimization/59445] [4.9 Regression] ICE in add_old_iv_candidates, at tree-ssa-loop-ivopts.c:2541

2013-12-10 Thread dominiq at lps dot ens.fr
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59445

--- Comment #6 from Dominique d'Humieres dominiq at lps dot ens.fr ---
 What is the equivalent of -march=?

I configure with --with-arch=corei7 --with-cpu=corei7.


[Bug tree-optimization/59445] [4.9 Regression] ICE in add_old_iv_candidates, at tree-ssa-loop-ivopts.c:2541

2013-12-10 Thread hjl.tools at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59445

--- Comment #8 from H.J. Lu hjl.tools at gmail dot com ---
(In reply to H.J. Lu from comment #7)
 classpath/java/awt/image/SinglePixelPackedSampleModel.java
 is used on Linux.  Is there a way to compile it by hand
^ I meant isn't used.
 on Linux?


[Bug tree-optimization/59445] [4.9 Regression] ICE in add_old_iv_candidates, at tree-ssa-loop-ivopts.c:2541

2013-12-10 Thread hjl.tools at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59445

--- Comment #7 from H.J. Lu hjl.tools at gmail dot com ---
classpath/java/awt/image/SinglePixelPackedSampleModel.java
is used on Linux.  Is there a way to compile it by hand
on Linux?


[Bug tree-optimization/59445] [4.9 Regression] ICE in add_old_iv_candidates, at tree-ssa-loop-ivopts.c:2541

2013-12-10 Thread octoploid at yandex dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59445

Markus Trippelsdorf octoploid at yandex dot com changed:

   What|Removed |Added

 CC||octoploid at yandex dot com

--- Comment #9 from Markus Trippelsdorf octoploid at yandex dot com ---
This issue also happens when building LLVM.

Reduced:

markus@x4 llvm_build % cat test.ii
template typename _Iterator struct A;
template typename _Tp struct A_Tp * {
  typedef _Tp value_type;
  typedef int difference_type;
};
template typename _Compare struct B {};
template typename _Compare struct C {
  _Compare _M_comp;
  template typename _Value, typename _Iterator
  int operator()(_Value p1, _Iterator p2) {
return _M_comp(p1, *p2);
  }
};
template typename _Compare C_Compare __val_comp_iter(B_Compare);
template typename _RandomAccessIterator, typename _Compare
void __unguarded_linear_insert(_RandomAccessIterator p1, _Compare p2) {
  typename A_RandomAccessIterator::value_type a;
  _RandomAccessIterator b = p1;
  --b;
  while (p2(a, b)) {
*p1 = 0;
p1 = b;
--b;
  }
}
template typename _RandomAccessIterator, typename _Compare
void __insertion_sort(_RandomAccessIterator, _Compare p2) {
  for (_RandomAccessIterator c;; ++c)
__unguarded_linear_insert(c, __val_comp_iter(p2));
}
template typename _RandomAccessIterator, typename _Distance, typename
_Compare
void __chunk_insertion_sort(_RandomAccessIterator, _Distance, _Compare p3) {
  _RandomAccessIterator d;
  __insertion_sort(d, p3);
}
template typename _RandomAccessIterator, typename _Pointer, typename _Compare
void __merge_sort_with_buffer(_RandomAccessIterator p1, _Pointer, _Compare p3)
{
  __chunk_insertion_sort(p1, 0, p3);
}
template typename _RandomAccessIterator, typename _Pointer, typename
_Distance,
  typename _Compare
void __stable_sort_adaptive(_RandomAccessIterator, _Pointer, _Distance,
_Compare p4) {
  _RandomAccessIterator e;
  __merge_sort_with_buffer(e, 0, p4);
}
template typename _RandomAccessIterator, typename _Compare
void __stable_sort(_RandomAccessIterator p1, _Compare p2) {
  __stable_sort_adaptive(
  p1, 0, typename A_RandomAccessIterator::difference_type(), p2);
}
template typename _RandomAccessIterator, typename _Compare
void stable_sort(_RandomAccessIterator, _RandomAccessIterator p2, _Compare) {
  B_Compare f;
  __stable_sort(p2, f);
}
class D {
public:
  void m_fn1();
};
class F {
  struct G {
D MFI;
int operator()(int p1, int p2) {
  if (p1)
return 0;
  if (p2)
return 1;
  MFI.m_fn1();
}
  };
  void m_fn1(int p1) const;
};
void F::m_fn1(int p1) const {
  int *g, *h;
  stable_sort(h, g, G());
}

markus@x4 llvm_build % g++ -O2 -c test.ii
test.ii: In member function ‘void F::m_fn1(int) const’:
test.ii:74:6: internal compiler error: in add_old_iv_candidates, at
tree-ssa-loop-ivopts.c:2541

[Bug tree-optimization/59445] [4.9 Regression] ICE in add_old_iv_candidates, at tree-ssa-loop-ivopts.c:2541

2013-12-10 Thread octoploid at yandex dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59445

Markus Trippelsdorf octoploid at yandex dot com changed:

   What|Removed |Added

 CC||amker.cheng at gmail dot com

--- Comment #10 from Markus Trippelsdorf octoploid at yandex dot com ---
Started with r205848.


[Bug tree-optimization/59445] [4.9 Regression] ICE in add_old_iv_candidates, at tree-ssa-loop-ivopts.c:2541

2013-12-10 Thread hjl.tools at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59445

H.J. Lu hjl.tools at gmail dot com changed:

   What|Removed |Added

 Target|x86_64-apple-darwin13   |
 Status|WAITING |NEW
   Host|x86_64-apple-darwin13   |
  Build|x86_64-apple-darwin13   |


[Bug tree-optimization/59445] [4.9 Regression] ICE in add_old_iv_candidates, at tree-ssa-loop-ivopts.c:2541

2013-12-10 Thread dominiq at lps dot ens.fr
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59445

--- Comment #11 from Dominique d'Humieres dominiq at lps dot ens.fr ---
 Started with r205848.

Well, the assert at line 2541 has been introduced in the revision:

+gcc_assert (gimple_bb (phi) == data-current_loop-header);

and it was in the original patch et
http://gcc.gnu.org/ml/gcc-patches/2013-12/msg00630.html, but without
explanation for it.


[Bug tree-optimization/59445] [4.9 Regression] ICE in add_old_iv_candidates, at tree-ssa-loop-ivopts.c:2541

2013-12-10 Thread howarth at nitro dot med.uc.edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59445

--- Comment #12 from Jack Howarth howarth at nitro dot med.uc.edu ---
Added Jeff Law since he reviewed and approved the offending patch.


[Bug tree-optimization/59445] [4.9 Regression] ICE in add_old_iv_candidates, at tree-ssa-loop-ivopts.c:2541

2013-12-10 Thread amker.cheng at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59445

--- Comment #13 from bin.cheng amker.cheng at gmail dot com ---
Sorry for bothering, I have reverted the patch.  Will investigate it.


[Bug tree-optimization/59445] [4.9 Regression] ICE in add_old_iv_candidates, at tree-ssa-loop-ivopts.c:2541

2013-12-10 Thread amker.cheng at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59445

--- Comment #14 from bin.cheng amker.cheng at gmail dot com ---
I found out the root cause of this ICE and will use the simplified code given
by comment#9 as an example.

The gimple dump before IVOPT is like:

  bb 2:

  bb 3:
  # c_2 = PHI c_5(D)(2), c_3(9)
  __val_comp_iterF::G (D.4949);
  p2 = D.4950;
  c_6 = c_2 + 4294967292;
  _21 = MEM[(int *)c_2 + 4294967292B];
  if (a_11(D) != 0)
goto bb 4;
  else
goto bb 5;

  bb 4:
  c_3 = c_2 + 4;
  goto bb 9;

  bb 5:
  goto bb 7;

  bb 6:
  # c_23 = PHI c_28(11), c_7(10)
  # _24 = PHI _29(11), _22(10)

  bb 7:
  # c_20 = PHI c_15(6), c_2(5)
  # c_15 = PHI c_23(6), c_6(5)
  # _26 = PHI _24(6), _21(5)
  if (_26 != 0)
goto bb 11;
  else
goto bb 8;

  bb 8:
  D::m_fn1 (MEM[(struct G *)p2].MFI);
  if (_13(D) != 0)
goto bb 10;
  else
goto bb 4;

  bb 9:
  goto bb 3;

  bb 10:
  *c_20 = 0;
  c_7 = c_15 + 4294967292;
  _22 = *c_7;
  goto bb 6;

  bb 11:
  *c_20 = 0;
  c_28 = c_15 + 4294967292;
  _29 = *c_28;
  goto bb 6;

With the patch:
STEP1: # c_20 = PHI c_15(6), c_2(5) is recognized as an iv. 
STEP2: Since # c_15 = PHI c_23(6), c_6(5) comes from a merging conditional
branches, it shouldn't be marked as a biv in mark_bivs.
STEP3: When mark_bivs handling # c_20 = PHI c_15(6), c_2(5),it should know
that this is a peeled iv and not mark either iv(c_20) or incr_iv(c_15) as bivs.

Unfortunately, this patch should add logic in mark_bivs to skip peeled iv,
rather than give an assert later when adding candidates for bivs.

The following patch should fix this problem:
@@ -1074,7 +1074,7 @@ find_bivs (struct ivopts_data *data)
 static void
 mark_bivs (struct ivopts_data *data)
 {
-  gimple phi;
+  gimple phi, def;
   tree var;
   struct iv *iv, *incr_iv;
   struct loop *loop = data-current_loop;
@@ -1090,6 +1090,13 @@ mark_bivs (struct ivopts_data *data)
 continue;

   var = PHI_ARG_DEF_FROM_EDGE (phi, loop_latch_edge (loop));
+  def = SSA_NAME_DEF_STMT (var);
+  /* Don't mark iv peeled from other one as biv.  */
+  if (def
+   gimple_code (def) == GIMPLE_PHI
+   gimple_bb (def) == loop-header)
+continue;
+
   incr_iv = get_iv (data, var);
   if (!incr_iv)
 continue;

PS, the example code can be optimized with fixed version patch by recognizing
more address ivs.  I attached the generated assembly code for arm cortex-m3.


[Bug tree-optimization/59445] [4.9 Regression] ICE in add_old_iv_candidates, at tree-ssa-loop-ivopts.c:2541

2013-12-10 Thread amker.cheng at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59445

--- Comment #15 from bin.cheng amker.cheng at gmail dot com ---
Created attachment 31414
  -- http://gcc.gnu.org/bugzilla/attachment.cgi?id=31414action=edit
The generated assembly with/without patch for code in comment #9 on cortex-m3