public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Committed] Fix PR 32399, ICE with iv-opts and POINTER PLUS and casting to size_t
@ 2007-08-04  0:32 Andrew Pinski
  0 siblings, 0 replies; only message in thread
From: Andrew Pinski @ 2007-08-04  0:32 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 773 bytes --]

Hi,
  The problem is that for add_to_parts when we already have a base and
an index, we try to add to the base but that ICEs as the base is a
pointer and we are trying with add a pointer to a pointer which is
invalid (but the code was written that way, there is a cast in the
code, note the code from which came wine has already been changed not
to invoke this weird behavior already).

This patch changes so we use POINTER_PLUS_EXPR and cast to the type of the base.

Committed as obvious after a bootstrap/test on i686-apple-darwin8.10
with no regressions.

Thanks,
Andrew Pinski

ChangeLog:

* tree-ssa-address.c (add_to_parts): Use POINTER_PLUS_EXPR
when adding to the base and convert ELT to sizetype instead of type.

* gcc.c-torture/compile/pr32399.c: New testcase.

[-- Attachment #2: fixpr32399.diff.txt --]
[-- Type: text/plain, Size: 1558 bytes --]

Index: testsuite/gcc.c-torture/compile/pr32399.c
===================================================================
--- testsuite/gcc.c-torture/compile/pr32399.c	(revision 0)
+++ testsuite/gcc.c-torture/compile/pr32399.c	(revision 0)
@@ -0,0 +1,16 @@
+void f(unsigned char *src, unsigned char *dst, int num, unsigned char *pos, unsigned char *diffuse, int hasdiffuse, unsigned char *specular, int hasspecular) {
+    int i;
+
+    for(i=num;i--;) {
+	float *p = (float *) ((__SIZE_TYPE__) dst + (__SIZE_TYPE__) pos);
+        if(hasdiffuse) {
+            unsigned int *dstColor = (unsigned int *) (dst + i + (__SIZE_TYPE__) diffuse);
+            *dstColor = * (unsigned int *) ( ((__SIZE_TYPE__) src + (__SIZE_TYPE__) diffuse) + i);
+        }
+        if(hasspecular) {
+            unsigned int *dstColor = (unsigned int *) (dst + i + (__SIZE_TYPE__) specular);
+            *dstColor = * (unsigned int *) ( ((__SIZE_TYPE__) src + (__SIZE_TYPE__) specular) + i);
+        }
+    }
+}
+
Index: tree-ssa-address.c
===================================================================
--- tree-ssa-address.c	(revision 127189)
+++ tree-ssa-address.c	(working copy)
@@ -422,9 +422,9 @@ add_to_parts (struct mem_address *parts,
 
   /* Add ELT to base.  */
   type = TREE_TYPE (parts->base);
-  parts->base = fold_build2 (PLUS_EXPR, type,
+  parts->base = fold_build2 (POINTER_PLUS_EXPR, type,
 			     parts->base,
-			     fold_convert (type, elt));
+			     fold_convert (sizetype, elt));
 }
 
 /* Finds the most expensive multiplication in ADDR that can be

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-08-04  0:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-04  0:32 [Committed] Fix PR 32399, ICE with iv-opts and POINTER PLUS and casting to size_t Andrew Pinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).