This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Introduce double_int_and_not
- From: Richard Guenther <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 29 Jul 2010 15:44:24 +0200 (CEST)
- Subject: [PATCH] Introduce double_int_and_not
I'm using that quite heavily in the new bit-CCP and also saw some
otehr uses.
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.
Richard.
2010-07-28 Richard Guenther <rguenther@suse.de>
* double-int.h (double_int_and_not): New function.
* combine.c (try_combine): Use it.
* tree-vrp.c (simplify_bit_ops_using_ranges): Likewise.
Index: gcc/double-int.h
===================================================================
*** gcc/double-int.h.orig 2010-07-29 15:01:24.000000000 +0200
--- gcc/double-int.h 2010-07-29 15:11:40.000000000 +0200
*************** static inline double_int
*** 158,164 ****
double_int_not (double_int a)
{
a.low = ~a.low;
! a.high = ~ a.high;
return a;
}
--- 158,164 ----
double_int_not (double_int a)
{
a.low = ~a.low;
! a.high = ~a.high;
return a;
}
*************** double_int_and (double_int a, double_int
*** 182,187 ****
--- 182,197 ----
return a;
}
+ /* Returns A & ~B. */
+
+ static inline double_int
+ double_int_and_not (double_int a, double_int b)
+ {
+ a.low &= ~b.low;
+ a.high &= ~b.high;
+ return a;
+ }
+
/* Returns A ^ B. */
static inline double_int
Index: gcc/combine.c
===================================================================
*** gcc/combine.c.orig 2010-07-28 12:30:39.000000000 +0200
--- gcc/combine.c 2010-07-29 15:13:02.000000000 +0200
*************** try_combine (rtx i3, rtx i2, rtx i1, int
*** 2601,2607 ****
i = double_int_and (i, m);
m = double_int_lshift (m, offset, HOST_BITS_PER_DOUBLE_INT, false);
i = double_int_lshift (i, offset, HOST_BITS_PER_DOUBLE_INT, false);
! o = double_int_ior (double_int_and (o, double_int_not (m)), i);
combine_merges++;
subst_insn = i3;
--- 2601,2607 ----
i = double_int_and (i, m);
m = double_int_lshift (m, offset, HOST_BITS_PER_DOUBLE_INT, false);
i = double_int_lshift (i, offset, HOST_BITS_PER_DOUBLE_INT, false);
! o = double_int_ior (double_int_and_not (o, m), i);
combine_merges++;
subst_insn = i3;
Index: gcc/tree-vrp.c
===================================================================
*** gcc/tree-vrp.c.orig 2010-07-22 15:02:30.000000000 +0200
--- gcc/tree-vrp.c 2010-07-29 15:13:33.000000000 +0200
*************** simplify_bit_ops_using_ranges (gimple_st
*** 6953,6967 ****
switch (gimple_assign_rhs_code (stmt))
{
case BIT_AND_EXPR:
! mask = double_int_and (may_be_nonzero0,
! double_int_not (must_be_nonzero1));
if (double_int_zero_p (mask))
{
op = op0;
break;
}
! mask = double_int_and (may_be_nonzero1,
! double_int_not (must_be_nonzero0));
if (double_int_zero_p (mask))
{
op = op1;
--- 6953,6965 ----
switch (gimple_assign_rhs_code (stmt))
{
case BIT_AND_EXPR:
! mask = double_int_and_not (may_be_nonzero0, must_be_nonzero1);
if (double_int_zero_p (mask))
{
op = op0;
break;
}
! mask = double_int_and_not (may_be_nonzero1, must_be_nonzero0);
if (double_int_zero_p (mask))
{
op = op1;
*************** simplify_bit_ops_using_ranges (gimple_st
*** 6969,6983 ****
}
break;
case BIT_IOR_EXPR:
! mask = double_int_and (may_be_nonzero0,
! double_int_not (must_be_nonzero1));
if (double_int_zero_p (mask))
{
op = op1;
break;
}
! mask = double_int_and (may_be_nonzero1,
! double_int_not (must_be_nonzero0));
if (double_int_zero_p (mask))
{
op = op0;
--- 6967,6979 ----
}
break;
case BIT_IOR_EXPR:
! mask = double_int_and_not (may_be_nonzero0, must_be_nonzero1);
if (double_int_zero_p (mask))
{
op = op1;
break;
}
! mask = double_int_and_not (may_be_nonzero1, must_be_nonzero0);
if (double_int_zero_p (mask))
{
op = op0;