diff mbox

Fix PR77937

Message ID 41b75544-3795-6c84-c9b4-6dcaf4829add@linux.vnet.ibm.com
State New
Headers show

Commit Message

Bill Schmidt Oct. 13, 2016, 1:14 a.m. UTC
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77937 reports an ICE in SLSR
where a POINTER_PLUS_EXPR occurs with a candidate increment of -1.  This
is supposed to be prevented by code in analyze_increments, since replacement
of such a candidate is not guaranteed to be profitable.  The test for this
was inadequate.  This patch replaces it with the correct check, determining
whether the type of the candidate is a pointer type.

Bootstrapped and tested on powerpc64le-unknown-linux-gnu, committed.

Thanks,
Bill


2016-10-12  Bill Schmidt  <wschmidt@linux.vnet.ibm.com>

	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.

Comments

Markus Trippelsdorf Oct. 13, 2016, 4:53 a.m. UTC | #1
On 2016.10.12 at 20:14 -0500, Bill Schmidt wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77937 reports an ICE in SLSR
> where a POINTER_PLUS_EXPR occurs with a candidate increment of -1.  This
> is supposed to be prevented by code in analyze_increments, since replacement
> of such a candidate is not guaranteed to be profitable.  The test for this
> was inadequate.  This patch replaces it with the correct check, determining
> whether the type of the candidate is a pointer type.
> 
> Bootstrapped and tested on powerpc64le-unknown-linux-gnu, committed.

Please commit the small testcase from the bug, too.

Thanks.
diff mbox

Patch

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