This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
RFC: Fix PR/11968: Handle pointer constant overflow
- From: "H. J. Lu" <hjl at lucon dot org>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 19 Aug 2003 17:14:21 -0700
- Subject: RFC: Fix PR/11968: Handle pointer constant overflow
When POINTER_SIZE < BITS_PER_WORD, pointer constant overflow is
ignored. As the result, pointer computation may be corrupted. Does
this patch make any senses?
H.J.
---
2003-08-19 H.J. Lu <hongjiu.lu@intel.com>
* expr.c (expand_expr): Handle pointer constant overflow.
--- gcc/expr.c.pointer 2003-08-18 08:40:16.000000000 -0700
+++ gcc/expr.c 2003-08-19 17:11:49.000000000 -0700
@@ -6787,9 +6787,17 @@ expand_expr (exp, target, tmode, modifie
which can result in (plus xx (const_int 0)), which can get
simplified by validate_replace_rtx during virtual register
instantiation, which can result in unrecognizable insns.
- Avoid this by forcing all overflows into registers. */
- if (TREE_CONSTANT_OVERFLOW (exp)
- && modifier != EXPAND_INITIALIZER)
+ Avoid this by forcing all overflows into registers. We also
+ need to check if there is a pointer overflow. */
+ if ((TREE_CONSTANT_OVERFLOW (exp)
+ || (POINTER_SIZE < BITS_PER_WORD
+ && POINTER_TYPE_P (type)
+ && TREE_INT_CST_HIGH (exp) == 0
+ && ((INTVAL (temp)
+ & ((HOST_WIDE_INT) 1 << (POINTER_SIZE - 1)))
+ != ((HOST_WIDE_INT) TREE_INT_CST_LOW (exp)
+ & ((HOST_WIDE_INT) 1 << (BITS_PER_WORD - 1))))))
+ && modifier != EXPAND_INITIALIZER)
temp = force_reg (mode, temp);
return temp;