[PATCH] add VRP for bitwise OR and AND: v3
Sat Aug 12 14:51:00 GMT 2006
On 8/12/06, Denis Vlasenko <email@example.com> wrote:
> * tree-vrp.c (extract_range_from_binary_expr):
> add value range propagation for bitwise AND/OR
> Patch is against gcc-4.2-20060805.
> Since unmodified gcc-4.2-20060805 snapshot does not bootstrap
> for me, I only verified that "make all-gcc" build
> of gcc-4.2-20060805 on i386-pc-linux-gnu
> with this patch succeeds.
> However, I successfully bootstrapped gcc-4.1.1 with this patch.
+/* Combines MIN and MAX as follows:
+ MIN = 01010010101001010010
+ MAX = 01010010100000010010
+ result: 01010010100000000000. */
+find_common_set_bits (tree min, tree max)
You should document these with an english sentence do clarify
what this function (and find_common_unset_bits) does. Certainly
the function name doesn't match the workings if I apply my own
+integer_nonnegative_range (value_range_t *vr)
+ return (vr->type == VR_RANGE
+ && TREE_CODE (vr->min) == INTEGER_CST
+ && tree_expr_nonnegative_p (vr->min)
+ && TREE_CODE (vr->max) == INTEGER_CST);
What about ~[TYPE_MIN_VALUE, n] with n >= -1? I don't think
we do any canonicalization of ranges and anti-ranges.
You can combine the cases for BIT_AND_EXPR and BIT_IOR_EXPR
by using 'code' in place of BIT_AND_EXPR and BIT_IOR_EXPR
in the implementation.
Also the patch lacks testcases, both for correctness and testing
transformations (like why negative ranges are excluded, or
signed types for the BIT_IOR_EXPR transformations).
More information about the Gcc-patches