diff options
author | H.J. Lu <hongjiu.lu@intel.com> | 2012-04-11 19:31:45 +0000 |
---|---|---|
committer | H.J. Lu <hongjiu.lu@intel.com> | 2012-04-11 19:31:45 +0000 |
commit | e37786b5518ef8ccf138fcd925a02616460bd528 (patch) | |
tree | a22fa5858f537ac51f83ae37d539fb42a9c209ab /gcc/emit-rtl.c | |
parent | c2ec2af5284a3f121156bba92683c646f23bc5f5 (diff) |
Check for incompatible pointer sign extension
gcc/
PR rtl-optimization/52876
* emit-rtl.c (set_reg_attrs_from_value): Handle arbitrary value.
Don't call mark_reg_pointer for incompatible pointer sign
extension.
* reginfo.c (reg_scan_mark_refs): Call set_reg_attrs_from_value
directly.
gcc/testsuite
PR rtl-optimization/52876
* gcc.target/i386/pr52876.c: New.
git-svn-id: https://gcc.gnu.org/svn/gcc/trunk@186351 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/emit-rtl.c')
-rw-r--r-- | gcc/emit-rtl.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/gcc/emit-rtl.c b/gcc/emit-rtl.c index 8d7d4417d59..9da585c35a7 100644 --- a/gcc/emit-rtl.c +++ b/gcc/emit-rtl.c @@ -970,6 +970,22 @@ void set_reg_attrs_from_value (rtx reg, rtx x) { int offset; + bool can_be_reg_pointer = true; + + /* Don't call mark_reg_pointer for incompatible pointer sign + extension. */ + while (GET_CODE (x) == SIGN_EXTEND + || GET_CODE (x) == ZERO_EXTEND + || GET_CODE (x) == TRUNCATE + || (GET_CODE (x) == SUBREG && subreg_lowpart_p (x))) + { +#if defined(POINTERS_EXTEND_UNSIGNED) && !defined(HAVE_ptr_extend) + if ((GET_CODE (x) == SIGN_EXTEND && POINTERS_EXTEND_UNSIGNED) + || (GET_CODE (x) != SIGN_EXTEND && ! POINTERS_EXTEND_UNSIGNED)) + can_be_reg_pointer = false; +#endif + x = XEXP (x, 0); + } /* Hard registers can be reused for multiple purposes within the same function, so setting REG_ATTRS, REG_POINTER and REG_POINTER_ALIGN @@ -983,14 +999,14 @@ set_reg_attrs_from_value (rtx reg, rtx x) if (MEM_OFFSET_KNOWN_P (x)) REG_ATTRS (reg) = get_reg_attrs (MEM_EXPR (x), MEM_OFFSET (x) + offset); - if (MEM_POINTER (x)) + if (can_be_reg_pointer && MEM_POINTER (x)) mark_reg_pointer (reg, 0); } else if (REG_P (x)) { if (REG_ATTRS (x)) update_reg_offset (reg, x, offset); - if (REG_POINTER (x)) + if (can_be_reg_pointer && REG_POINTER (x)) mark_reg_pointer (reg, REGNO_POINTER_ALIGN (REGNO (x))); } } |