[Bug tree-optimization/77937] [7 Regression] ICE: in replace_one_candidate, at gimple-ssa-strength-reduction.c:3370
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77937 --- Comment #17 from Bill Schmidt --- Author: wschmidt Date: Wed Oct 19 13:35:14 2016 New Revision: 241342 URL: https://gcc.gnu.org/viewcvs?rev=241342=gcc=rev Log: 2016-10-19 Bill SchmidtPR tree-optimization/77916 PR tree-optimization/77937 * gimple-ssa-strength-reduction.c (analyze_increments): Remove stopgap fix. (insert_initializers): Requirement of initializer for -1 should be based on pointer-typedness of the candidate basis. Modified: trunk/gcc/ChangeLog trunk/gcc/gimple-ssa-strength-reduction.c
[Bug tree-optimization/77937] [7 Regression] ICE: in replace_one_candidate, at gimple-ssa-strength-reduction.c:3370
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77937 Bill Schmidt changed: What|Removed |Added Status|NEW |RESOLVED Resolution|--- |FIXED --- Comment #16 from Bill Schmidt --- Fixed. Further work for similar issues is being done under https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77916.
[Bug tree-optimization/77937] [7 Regression] ICE: in replace_one_candidate, at gimple-ssa-strength-reduction.c:3370
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77937 --- Comment #15 from Bill Schmidt --- Author: wschmidt Date: Mon Oct 17 14:24:21 2016 New Revision: 241244 URL: https://gcc.gnu.org/viewcvs?rev=241244=gcc=rev Log: [gcc] 2016-10-17 Bill SchmidtBackport from mainline 2016-10-12 Bill Schmidt PR tree-optimization/77937 * gimple-ssa-strength-reduction.c (analyze_increments): Use POINTER_TYPE_P on the candidate type to determine whether candidates in this chain require pointer arithmetic. 2016-10-13 Bill Schmidt PR tree-optimization/77937 * gimple-ssa-strength-reduction.c (analyze_increments): Set cost to infinite when we have a pointer with an increment of -1. [gcc/testsuite] 2016-10-17 Bill Schmidt Backport from mainline 2016-10-13 Bill Schmidt PR tree-optimization/77937 * gcc.dg/torture/pr77937-1.c: New. * gcc.dg/torture/pr77937-2.c: New. Added: branches/gcc-5-branch/gcc/testsuite/gcc.dg/torture/pr77937-1.c branches/gcc-5-branch/gcc/testsuite/gcc.dg/torture/pr77937-2.c Modified: branches/gcc-5-branch/gcc/ChangeLog branches/gcc-5-branch/gcc/gimple-ssa-strength-reduction.c branches/gcc-5-branch/gcc/testsuite/ChangeLog
[Bug tree-optimization/77937] [7 Regression] ICE: in replace_one_candidate, at gimple-ssa-strength-reduction.c:3370
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77937 --- Comment #14 from Bill Schmidt --- Author: wschmidt Date: Mon Oct 17 14:22:22 2016 New Revision: 241243 URL: https://gcc.gnu.org/viewcvs?rev=241243=gcc=rev Log: [gcc] 2016-10-17 Bill SchmidtBackport from mainline 2016-10-12 Bill Schmidt PR tree-optimization/77937 * gimple-ssa-strength-reduction.c (analyze_increments): Use POINTER_TYPE_P on the candidate type to determine whether candidates in this chain require pointer arithmetic. 2016-10-13 Bill Schmidt PR tree-optimization/77937 * gimple-ssa-strength-reduction.c (analyze_increments): Set cost to infinite when we have a pointer with an increment of -1. [gcc/testsuite] 2016-10-17 Bill Schmidt Backport from mainline 2016-10-13 Bill Schmidt PR tree-optimization/77937 * gcc.dg/torture/pr77937-1.c: New. * gcc.dg/torture/pr77937-2.c: New. Added: branches/gcc-6-branch/gcc/testsuite/gcc.dg/torture/pr77937-1.c branches/gcc-6-branch/gcc/testsuite/gcc.dg/torture/pr77937-2.c Modified: branches/gcc-6-branch/gcc/ChangeLog branches/gcc-6-branch/gcc/gimple-ssa-strength-reduction.c branches/gcc-6-branch/gcc/testsuite/ChangeLog
[Bug tree-optimization/77937] [7 Regression] ICE: in replace_one_candidate, at gimple-ssa-strength-reduction.c:3370
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77937 --- Comment #13 from Bill Schmidt --- Author: wschmidt Date: Thu Oct 13 19:50:41 2016 New Revision: 241139 URL: https://gcc.gnu.org/viewcvs?rev=241139=gcc=rev Log: 2016-10-13 Bill SchmidtPR tree-optimization/77937 * gcc.dg/torture/pr77937-1.c: New. * gcc.dg/torture/pr77937-2.c: New. Added: trunk/gcc/testsuite/gcc.dg/torture/pr77937-1.c trunk/gcc/testsuite/gcc.dg/torture/pr77937-2.c Modified: trunk/gcc/testsuite/ChangeLog
[Bug tree-optimization/77937] [7 Regression] ICE: in replace_one_candidate, at gimple-ssa-strength-reduction.c:3370
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77937 --- Comment #12 from Bill Schmidt --- Just saw your request to include the test case. I will do this but may ask you to review the dejagnu bits for accuracy for your target, as these don't fire on arches I regularly build for.
[Bug tree-optimization/77937] [7 Regression] ICE: in replace_one_candidate, at gimple-ssa-strength-reduction.c:3370
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77937 --- Comment #11 from Bill Schmidt --- Author: wschmidt Date: Thu Oct 13 15:34:22 2016 New Revision: 241125 URL: https://gcc.gnu.org/viewcvs?rev=241125=gcc=rev Log: 2016-10-13 Bill SchmidtPR tree-optimization/77937 * gimple-ssa-strength-reduction.c (analyze_increments): Set cost to infinite when we have a pointer with an increment of -1. Modified: trunk/gcc/ChangeLog trunk/gcc/gimple-ssa-strength-reduction.c
[Bug tree-optimization/77937] [7 Regression] ICE: in replace_one_candidate, at gimple-ssa-strength-reduction.c:3370
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77937 --- Comment #10 from Markus Trippelsdorf --- It still happens, but on another unit this time: markus@x4 ffmpeg % cat h264dsp.i extern int fn2(int); extern int fn3(int); int a, b, c; void fn1(long p1) { char *d; for (;; d += p1) { d[0] = fn2(1 >> a); fn3(0); fn3(c >> a); d[1] = fn3(d[1] * b + c >> a); d[4] = fn3(d[4] * b + c >> a); d[5] = fn3(d[5] * b + c >> a); } } markus@x4 ffmpeg % gcc -march=amdfam10 -O3 -c -S h264dsp.i h264dsp.i: In function ‘fn1’: h264dsp.i:4:6: internal compiler error: in replace_one_candidate, at gimple-ssa-strength-reduction.c:3369 void fn1(long p1) { ^~~ Simply building ffmpeg with -march=amdfam10 finds these bugs. Please consider reverting your original patch until you come up with solution.
[Bug tree-optimization/77937] [7 Regression] ICE: in replace_one_candidate, at gimple-ssa-strength-reduction.c:3370
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77937 --- Comment #9 from Bill Schmidt --- Keeping this open until the fix has some burn-in time, planning to backport to GCC 6 and 5.
[Bug tree-optimization/77937] [7 Regression] ICE: in replace_one_candidate, at gimple-ssa-strength-reduction.c:3370
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77937 --- Comment #8 from Bill Schmidt --- Author: wschmidt Date: Thu Oct 13 01:08:20 2016 New Revision: 241082 URL: https://gcc.gnu.org/viewcvs?rev=241082=gcc=rev Log: 2016-10-12 Bill SchmidtPR tree-optimization/77937 * gimple-ssa-strength-reduction.c (analyze_increments): Use POINTER_TYPE_P on the candidate type to determine whether candidates in this chain require pointer arithmetic. Modified: trunk/gcc/ChangeLog trunk/gcc/gimple-ssa-strength-reduction.c
[Bug tree-optimization/77937] [7 Regression] ICE: in replace_one_candidate, at gimple-ssa-strength-reduction.c:3370
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77937 --- Comment #7 from Bill Schmidt --- OK, I can reproduce now, and understand the problem better. This patch fixes the problem. I'll regstrap it and get it committed shortly. Index: gcc/gimple-ssa-strength-reduction.c === --- gcc/gimple-ssa-strength-reduction.c (revision 240946) +++ gcc/gimple-ssa-strength-reduction.c (working copy) @@ -2816,8 +2816,7 @@ analyze_increments (slsr_cand_t first_dep, machine else if (incr == 0 || incr == 1 || (incr == -1 - && (gimple_assign_rhs_code (first_dep->cand_stmt) - != POINTER_PLUS_EXPR))) + && !POINTER_TYPE_P (first_dep->cand_type))) incr_vec[i].cost = COST_NEUTRAL; /* FORNOW: If we need to add an initializer, give up if a cast from
[Bug tree-optimization/77937] [7 Regression] ICE: in replace_one_candidate, at gimple-ssa-strength-reduction.c:3370
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77937 --- Comment #6 from Markus Trippelsdorf --- Unfortunately it doesn't work: dirac.i:3:6: internal compiler error: Segmentation fault void fn1(char *p1, int p2) { ^~~ 0xb6d367 crash_signal ../../gcc/gcc/toplev.c:337 0x7ff87981f10f ??? /home/markus/glibc/signal/../sysdeps/unix/sysv/linux/x86_64/sigaction.c:0 0xb9bad2 contains_struct_check(tree_node*, tree_node_structure_enum, char const*, int, char const*) ../../gcc/gcc/tree.h:3144 0xb9bad2 verify_gimple_assign_binary ../../gcc/gcc/tree-cfg.c:3732 0xbb479b verify_gimple_in_cfg(function*, bool) ../../gcc/gcc/tree-cfg.c:5135 0xa97737 execute_function_todo ../../gcc/gcc/passes.c:1964 0xa987ec execute_todo ../../gcc/gcc/passes.c:2014
[Bug tree-optimization/77937] [7 Regression] ICE: in replace_one_candidate, at gimple-ssa-strength-reduction.c:3370
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77937 Bill Schmidt changed: What|Removed |Added Target||x86_64-pc-linux-gnu --- Comment #5 from Bill Schmidt --- OK, thanks. While I get a cross built, could you please try the following patch? Index: gcc/gimple-ssa-strength-reduction.c === --- gcc/gimple-ssa-strength-reduction.c (revision 240946) +++ gcc/gimple-ssa-strength-reduction.c (working copy) @@ -3367,7 +3367,7 @@ replace_one_candidate (slsr_cand_t c, unsigned i, { tree stride_type = TREE_TYPE (c->stride); tree orig_type = TREE_TYPE (orig_rhs2); - gcc_assert (repl_code != POINTER_PLUS_EXPR); + tree basis_type = TREE_TYPE (basis_name); if (types_compatible_p (orig_type, stride_type)) rhs2 = c->stride; @@ -3374,7 +3374,16 @@ replace_one_candidate (slsr_cand_t c, unsigned i, else rhs2 = introduce_cast_before_cand (c, orig_type, c->stride); - if (orig_code != MINUS_EXPR + if (POINTER_TYPE_P (basis_type)) + { + tree neg_stride = fold_unary (NEGATE_EXPR, sizetype, rhs2); + gimple_stmt_iterator gsi = gsi_for_stmt (c->cand_stmt); + gimple_assign_set_rhs_with_ops (, POINTER_PLUS_EXPR, + basis_name, neg_stride); + update_stmt (gsi_stmt (gsi)); + c->cand_stmt = gsi_stmt (gsi); + } + else if (orig_code != MINUS_EXPR || !operand_equal_p (basis_name, orig_rhs1, 0) || !operand_equal_p (rhs2, orig_rhs2, 0)) {
[Bug tree-optimization/77937] [7 Regression] ICE: in replace_one_candidate, at gimple-ssa-strength-reduction.c:3370
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77937 --- Comment #4 from Markus Trippelsdorf --- Well, -march=amdfam10 is of course x86_64-pc-linux-gnu.
[Bug tree-optimization/77937] [7 Regression] ICE: in replace_one_candidate, at gimple-ssa-strength-reduction.c:3370
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77937 --- Comment #3 from Bill Schmidt --- Does not reproduce on powerpc64le-unknown-linux-gnu. Can you please report the target triple?
[Bug tree-optimization/77937] [7 Regression] ICE: in replace_one_candidate, at gimple-ssa-strength-reduction.c:3370
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77937 Bill Schmidt changed: What|Removed |Added Assignee|unassigned at gcc dot gnu.org |wschmidt at gcc dot gnu.org Target Milestone|--- |7.0 --- Comment #2 from Bill Schmidt --- Mine to investigate -- looks like enabling copies to be handled properly has exposed another "opportunity" here. Looks like probably another issue with pointer addition.
[Bug tree-optimization/77937] [7 Regression] ICE: in replace_one_candidate, at gimple-ssa-strength-reduction.c:3370
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77937 Markus Trippelsdorf changed: What|Removed |Added Status|UNCONFIRMED |NEW Last reconfirmed||2016-10-11 CC||wschmidt at gcc dot gnu.org Ever confirmed|0 |1 --- Comment #1 from Markus Trippelsdorf --- Started with r240945: commit 41b5b58f52ee35f1efe7eeac644db6992dac5499 Author: wschmidtDate: Mon Oct 10 18:39:41 2016 + 2016-10-10 Bill Schmidt PR tree-optimization/77824 * gimple-ssa-strength-reduction.c (stmt_cost): Explicitly return zero cost for copies. (find_candidates_dom_walker::before_dom_children): Replace MODIFY_EXPR with SSA_NAME. (replace_mult_candidate): Likewise. (replace_profitable_candidates): Likewise.