[Bug middle-end/47383] ivopts miscompiles Pmode != ptr_mode
hjl.tools at gmail dot com
gcc-bugzilla@gcc.gnu.org
Fri Feb 4 04:13:00 GMT 2011
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47383
--- Comment #8 from H.J. Lu <hjl.tools at gmail dot com> 2011-02-04 04:12:59 UTC ---
(In reply to comment #7)
> > looks wrong since it assumes D.2750_34 can be negative. But
>
> sizetype values are sign-extended.
>
ivopts uses unsigned on purpose and create_mem_ref isn't prepared
to deal with. This isn't the right fix. It just shows we need to
properly sign-extended index when Pmode != ptr_mode:
diff --git a/gcc/tree-ssa-address.c b/gcc/tree-ssa-address.c
index a9ca835..4926a6d 100644
--- a/gcc/tree-ssa-address.c
+++ b/gcc/tree-ssa-address.c
@@ -45,6 +45,7 @@ along with GCC; see the file COPYING3. If not see
#include "expr.h"
#include "ggc.h"
#include "target.h"
+#include "langhooks.h"
/* TODO -- handling of symbols (according to Richard Hendersons
comments, http://gcc.gnu.org/ml/gcc-patches/2005-04/msg00949.html):
@@ -658,6 +659,13 @@ addr_to_parts (tree type, aff_tree *addr, tree iv_cand,
}
if (addr->rest)
add_to_parts (parts, fold_convert (sizetype, addr->rest));
+
+ if (Pmode != ptr_mode && parts->index)
+ {
+ parts->index = fold_convert (ssizetype, parts->index);
+ parts->index = fold_convert (lang_hooks.types.type_for_mode (Pmode, 0),
+ parts->index);
+ }
}
/* Force the PARTS to register. */
More information about the Gcc-bugs
mailing list