Summary: | [4.5 Regression] internal compiler error: in get_initial_def_for_induction, at tree-vect-loop.c:2431 | ||
---|---|---|---|
Product: | gcc | Reporter: | Matthias Kretz (Vir) <mkretz> |
Component: | tree-optimization | Assignee: | Richard Biener <rguenth> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | doko, irar, irar, rguenth |
Priority: | P2 | ||
Version: | 4.5.1 | ||
Target Milestone: | 4.5.3 | ||
Host: | Target: | ||
Build: | Known to work: | 4.5.0, 4.6.0 | |
Known to fail: | 4.5.1 | Last reconfirmed: | 2010-11-30 14:27:37 |
Attachments: |
preprocessed source which makes G++ 4.5.1 ICE
A reduced testcase patch |
Description
Matthias Kretz (Vir)
2010-11-30 13:49:16 UTC
Created attachment 22578 [details]
preprocessed source which makes G++ 4.5.1 ICE
Confirmed. This is a regression on the branch, trunk works, so maybe some patches need to be backported (PR45971 comes to my mind). Reducing. Created attachment 22583 [details] A reduced testcase [hjl@gnu-35 delta]$ /usr/gcc-4.5/bin/gcc -S -O3 testcase-min.cc testcase-min.cc: In function ‘void testVectors() [with V = Vc::Simple::Vector<short int>]’: testcase-min.cc:157:27: internal compiler error: in get_initial_def_for_induction, at tree-vect-loop.c:2431 Please submit a full bug report, with preprocessed source if appropriate. See <http://gcc.gnu.org/bugs.html> for instructions. [hjl@gnu-35 delta]$ It is caused by revision 161951: http://gcc.gnu.org/ml/gcc-cvs/2010-07/msg00305.html Mine then. C testcase that also ICEs on trunk: short *m; void test() { short x = 128; unsigned int i; for (i = 0; i < 128; ++i, x = (unsigned short)x + 1) m[i] = x; } we are confused wrt the address arithmetic in D.2720_6 = (long unsigned int) i_20; D.2721_7 = D.2720_6 * 2; D.2722_8 = pretmp.6_18 + D.2721_7; *D.2722_8 = x_19; and don't ICE with short m[128]; which just gives us m[i_20] = x_19; The access function that isn't a simple iv evolution is: (short int) {(short unsigned int) x_50, +, 1}_1 At analysis time (in the not copied loop) we analyse it to {128, +, 1}_1 instead as the loop bound is now non-constant after peeling a prologue: <bb 3>: # x_19 = PHI <x_12(4), x_50(22)> # i_20 = PHI <i_9(4), i_52(22)> # ivtmp.14_5 = PHI <ivtmp.14_27(4), ivtmp.14_55(22)> D.2690_6 = (long unsigned int) i_20; D.2691_7 = D.2690_6 * 2; D.2692_8 = pretmp.6_18 + D.2691_7; *D.2692_8 = x_19; i_9 = i_20 + 1; x.1_10 = (short unsigned int) x_19; D.2694_11 = x.1_10 + 1; x_12 = (short int) D.2694_11; ivtmp.14_27 = ivtmp.14_5 - 1; if (ivtmp.14_27 != 0) goto <bb 4>; else goto <bb 19>; in principle we can deal with that evolution just fine, but this discrepancy analysis vs. transformation time doesn't look too good. Created attachment 22587 [details]
patch
Patch I'm testing. Computes the induction PHI in the type of the evolution,
stripping conversions (sign-changing only for now) and re-applying them at
uses (by inserting another assignment that does the conversion in place for
the vectorized stmt).
*************** get_initial_def_for_induction (gimple iv *** 2656,2667 **** --- 2639,2664 ---- loop_arg = PHI_ARG_DEF_FROM_EDGE (iv_phi, latch_e); access_fn = analyze_scalar_evolution (iv_loop, PHI_RESULT (iv_phi)); + STRIP_NOPS (access_fn); gcc_assert (access_fn); this makes gcc_assert meaningless: STRIP_NOPS will segfault for NULL access_fn before the assert. Thanks, Ira On Thu, 2 Dec 2010, irar at il dot ibm.com wrote:
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46723
>
> Ira Rosen <irar at il dot ibm.com> changed:
>
> What |Removed |Added
> ----------------------------------------------------------------------------
> CC| |irar at il dot ibm.com
>
> --- Comment #8 from Ira Rosen <irar at il dot ibm.com> 2010-12-02 08:15:16 UTC ---
> *************** get_initial_def_for_induction (gimple iv
> *** 2656,2667 ****
> --- 2639,2664 ----
> loop_arg = PHI_ARG_DEF_FROM_EDGE (iv_phi, latch_e);
>
> access_fn = analyze_scalar_evolution (iv_loop, PHI_RESULT (iv_phi));
> + STRIP_NOPS (access_fn);
> gcc_assert (access_fn);
>
> this makes gcc_assert meaningless: STRIP_NOPS will segfault for NULL access_fn
> before the assert.
Ah, indeed. Of course we should never assert here (if we do the analysis
has wrongly determined we can handle the induction), but of course we
can't fail to vectorize at this point either ...
Thanks,
Richard.
Author: rguenth Date: Thu Dec 2 16:23:20 2010 New Revision: 167377 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=167377 Log: 2010-12-02 Richard Guenther <rguenther@suse.de> PR tree-optimization/46723 * tree-vect-loop.c (get_initial_def_for_induction): Strip conversions from the induction evolution and apply it to the result instead. * tree-vect-stmts.c (vect_get_vec_def_for_operand): Handle assigns for induction defs. * gcc.dg/torture/pr46723.c: New testcase. Added: trunk/gcc/testsuite/gcc.dg/torture/pr46723.c Modified: trunk/gcc/ChangeLog trunk/gcc/testsuite/ChangeLog trunk/gcc/tree-vect-loop.c trunk/gcc/tree-vect-stmts.c Fixed on trunk sofar. GCC 4.5.2 is being released, adjusting target milestone. the patch fixes the ICE on the 4.5 branch, no regressions on a i686-linux-gnu biarch build and test. Author: rguenth Date: Tue Mar 1 17:04:26 2011 New Revision: 170595 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=170595 Log: 2011-03-01 Richard Guenther <rguenther@suse.de> Backport from mainline 2011-03-01 Richard Guenther <rguenther@suse.de> PR tree-optimization/47890 * tree-vect-loop.c (get_initial_def_for_induction): Set related stmt properly. * gcc.dg/torture/pr47890.c: New testcase. 2010-12-01 Richard Guenther <rguenther@suse.de> PR tree-optimization/46723 * tree-vect-loop.c (get_initial_def_for_induction): Strip conversions from the induction evolution and apply it to the result instead. * tree-vect-stmts.c (vect_get_vec_def_for_operand): Handle assigns for induction defs. * gcc.dg/torture/pr46723.c: New testcase. Added: branches/gcc-4_5-branch/gcc/testsuite/gcc.dg/torture/pr46723.c branches/gcc-4_5-branch/gcc/testsuite/gcc.dg/torture/pr47890.c Modified: branches/gcc-4_5-branch/gcc/ChangeLog branches/gcc-4_5-branch/gcc/testsuite/ChangeLog branches/gcc-4_5-branch/gcc/tree-vect-loop.c branches/gcc-4_5-branch/gcc/tree-vect-stmts.c Fixed. |