On 10/31/13 03:15, Ilya Enkovich wrote:
Hi,
Here is a patch which adds support for bound constant to be used as
DECL_INITIAL for constant static bounds generated by compiler.
Thanks,
Ilya
--
gcc/
2013-10-23 Ilya Enkovich <ilya.enkov...@intel.com>
* emit-rtl.c (immed_double_const): Support MODE_POINTER_BOUNDS.
* explow.c (trunc_int_for_mode): Likewise.
* varpool.c (ctor_for_folding): Do not fold constant
bounds vars.
I'm having a bit of trouble reconciling "add support for bound constant
to be used as DECL_INITIAL" rationale text and the actual patch.
From reading the patch it appears that you want to allow generation of
immediate constants for objects with MODE_POINTER_BOUNDS. OK, I can see
how that is useful.
I can kindof see how you want to error out if someone asks for a
constant to be truncated to MODE_POINTER_BOUNDS. Did this trip in
practice or is it preemptive?
diff --git a/gcc/varpool.c b/gcc/varpool.c
index 2eb1fc1..d9c08c1 100644
--- a/gcc/varpool.c
+++ b/gcc/varpool.c
@@ -254,6 +254,12 @@ ctor_for_folding (tree decl)
&& TREE_CODE (decl) != CONST_DECL)
return error_mark_node;
+ /* Static constant bounds are created to be
+ used instead of constants and therefore
+ do not let folding it. */
+ if (POINTER_BOUNDS_P (decl))
+ return error_mark_node;
Here's the part I'm struggling a bit with. Why did you need this?
Isn't this going to prevent that DECL from being used in folding? The
bounds shouldn't really affect that AFAICT.
jeff