Patchwork Fold &a < &a + 4 with -fno-strict-overflow

login
register
mail settings
Submitter Richard Guenther
Date Aug. 24, 2011, 12:50 p.m.
Message ID <alpine.LNX.2.00.1108241449280.2130@zhemvz.fhfr.qr>
Download mbox | patch
Permalink /patch/111334/
State New
Headers show

Comments

Richard Guenther - Aug. 24, 2011, 12:50 p.m.
I noticed we do not optimize any of the vectorizer alias tests
with -fno-strict-overflow.  The following fixes this.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.

Richard.

2011-08-24  Richard Guenther  <rguenther@suse.de>

	* fold-const.c (fold_comparison): Fold &a < &a + 4 even
	with -fno-strict-overflow.

Patch

Index: gcc/fold-const.c
===================================================================
--- gcc/fold-const.c	(revision 178031)
+++ gcc/fold-const.c	(working copy)
@@ -8738,6 +8738,7 @@  fold_comparison (location_t loc, enum tr
 		   && operand_equal_p (offset0, offset1, 0)))
 	      && (code == EQ_EXPR
 		  || code == NE_EXPR
+		  || (indirect_base0 && DECL_P (base0))
 		  || POINTER_TYPE_OVERFLOW_UNDEFINED))
 
 	    {
@@ -8777,6 +8778,7 @@  fold_comparison (location_t loc, enum tr
 	     6.5.6/8 and /9 with respect to the signed ptrdiff_t.  */
 	  else if (bitpos0 == bitpos1
 		   && ((code == EQ_EXPR || code == NE_EXPR)
+		       || (indirect_base0 && DECL_P (base0))
 		       || POINTER_TYPE_OVERFLOW_UNDEFINED))
 	    {
 	      /* By converting to signed size type we cover middle-end pointer