* [patch 2/8 tree-optimization]: Bitwise logic for fold_range_test and fold_truthop.
@ 2011-07-13 7:34 Kai Tietz
2011-07-13 10:28 ` Richard Guenther
0 siblings, 1 reply; 2+ messages in thread
From: Kai Tietz @ 2011-07-13 7:34 UTC (permalink / raw)
To: GCC Patches; +Cc: Richard Guenther
Hello,
This patch adds support to fold_range_test and to fold_truthop for
one-bit precision
typed bitwise-binary and bitwise-not expressions.
ChangeLog
2011-07-13 Kai Tietz <ktietz@redhat.com>
* fold-const.c (fold_range_test): Add
support for one-bit bitwise operations.
(fold_truthop): Likewise.
Bootstrapped and regression tested with prior patches of this series
for x86_64-pc-linux-gnu.
Ok for apply?
Regards,
Kai
Index: gcc/gcc/fold-const.c
===================================================================
--- gcc.orig/gcc/fold-const.c 2011-07-13 08:07:59.000000000 +0200
+++ gcc/gcc/fold-const.c 2011-07-13 08:59:26.117620200 +0200
@@ -4819,7 +4819,8 @@ fold_range_test (location_t loc, enum tr
tree op0, tree op1)
{
int or_op = (code == TRUTH_ORIF_EXPR
- || code == TRUTH_OR_EXPR);
+ || code == TRUTH_OR_EXPR
+ || code == BIT_IOR_EXPR);
int in0_p, in1_p, in_p;
tree low0, low1, low, high0, high1, high;
bool strict_overflow_p = false;
@@ -4890,7 +4891,7 @@ fold_range_test (location_t loc, enum tr
}
}
- return 0;
+ return NULL_TREE;
}
\f
/* Subroutine for fold_truthop: C is an INTEGER_CST interpreted as a P
@@ -5118,8 +5119,9 @@ fold_truthop (location_t loc, enum tree_
}
}
- code = ((code == TRUTH_AND_EXPR || code == TRUTH_ANDIF_EXPR)
- ? TRUTH_AND_EXPR : TRUTH_OR_EXPR);
+ if (code != BIT_AND_EXPR && code != BIT_IOR_EXPR)
+ code = ((code == TRUTH_AND_EXPR || code == TRUTH_ANDIF_EXPR)
+ ? TRUTH_AND_EXPR : TRUTH_OR_EXPR);
/* If the RHS can be evaluated unconditionally and its operands are
simple, it wins to evaluate the RHS unconditionally on machines
@@ -5134,7 +5136,7 @@ fold_truthop (location_t loc, enum tree_
&& simple_operand_p (rr_arg))
{
/* Convert (a != 0) || (b != 0) into (a | b) != 0. */
- if (code == TRUTH_OR_EXPR
+ if ((code == TRUTH_OR_EXPR || code == BIT_IOR_EXPR)
&& lcode == NE_EXPR && integer_zerop (lr_arg)
&& rcode == NE_EXPR && integer_zerop (rr_arg)
&& TREE_TYPE (ll_arg) == TREE_TYPE (rl_arg)
@@ -5145,7 +5147,7 @@ fold_truthop (location_t loc, enum tree_
build_int_cst (TREE_TYPE (ll_arg), 0));
/* Convert (a == 0) && (b == 0) into (a | b) == 0. */
- if (code == TRUTH_AND_EXPR
+ if ((code == TRUTH_AND_EXPR || code == BIT_AND_EXPR)
&& lcode == EQ_EXPR && integer_zerop (lr_arg)
&& rcode == EQ_EXPR && integer_zerop (rr_arg)
&& TREE_TYPE (ll_arg) == TREE_TYPE (rl_arg)
@@ -5209,7 +5211,8 @@ fold_truthop (location_t loc, enum tree_
fail. However, we can convert a one-bit comparison against zero into
the opposite comparison against that bit being set in the field. */
- wanted_code = (code == TRUTH_AND_EXPR ? EQ_EXPR : NE_EXPR);
+ wanted_code = ((code == TRUTH_AND_EXPR
+ || code == BIT_AND_EXPR) ? EQ_EXPR : NE_EXPR);
if (lcode != wanted_code)
{
if (l_const && integer_zerop (l_const) && integer_pow2p (ll_mask))
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [patch 2/8 tree-optimization]: Bitwise logic for fold_range_test and fold_truthop.
2011-07-13 7:34 [patch 2/8 tree-optimization]: Bitwise logic for fold_range_test and fold_truthop Kai Tietz
@ 2011-07-13 10:28 ` Richard Guenther
0 siblings, 0 replies; 2+ messages in thread
From: Richard Guenther @ 2011-07-13 10:28 UTC (permalink / raw)
To: Kai Tietz; +Cc: GCC Patches
On Wed, Jul 13, 2011 at 9:32 AM, Kai Tietz <ktietz70@googlemail.com> wrote:
> Hello,
>
> This patch adds support to fold_range_test and to fold_truthop for
> one-bit precision
> typed bitwise-binary and bitwise-not expressions.
This looks reasonable but I'd like to see testcases excercising the
foldings (by scanning the .original dump).
Richard.
> ChangeLog
>
> 2011-07-13 Kai Tietz <ktietz@redhat.com>
>
> * fold-const.c (fold_range_test): Add
> support for one-bit bitwise operations.
> (fold_truthop): Likewise.
>
> Bootstrapped and regression tested with prior patches of this series
> for x86_64-pc-linux-gnu.
> Ok for apply?
>
> Regards,
> Kai
>
> Index: gcc/gcc/fold-const.c
> ===================================================================
> --- gcc.orig/gcc/fold-const.c 2011-07-13 08:07:59.000000000 +0200
> +++ gcc/gcc/fold-const.c 2011-07-13 08:59:26.117620200 +0200
> @@ -4819,7 +4819,8 @@ fold_range_test (location_t loc, enum tr
> tree op0, tree op1)
> {
> int or_op = (code == TRUTH_ORIF_EXPR
> - || code == TRUTH_OR_EXPR);
> + || code == TRUTH_OR_EXPR
> + || code == BIT_IOR_EXPR);
> int in0_p, in1_p, in_p;
> tree low0, low1, low, high0, high1, high;
> bool strict_overflow_p = false;
> @@ -4890,7 +4891,7 @@ fold_range_test (location_t loc, enum tr
> }
> }
>
> - return 0;
> + return NULL_TREE;
> }
>
> /* Subroutine for fold_truthop: C is an INTEGER_CST interpreted as a P
> @@ -5118,8 +5119,9 @@ fold_truthop (location_t loc, enum tree_
> }
> }
>
> - code = ((code == TRUTH_AND_EXPR || code == TRUTH_ANDIF_EXPR)
> - ? TRUTH_AND_EXPR : TRUTH_OR_EXPR);
> + if (code != BIT_AND_EXPR && code != BIT_IOR_EXPR)
> + code = ((code == TRUTH_AND_EXPR || code == TRUTH_ANDIF_EXPR)
> + ? TRUTH_AND_EXPR : TRUTH_OR_EXPR);
>
> /* If the RHS can be evaluated unconditionally and its operands are
> simple, it wins to evaluate the RHS unconditionally on machines
> @@ -5134,7 +5136,7 @@ fold_truthop (location_t loc, enum tree_
> && simple_operand_p (rr_arg))
> {
> /* Convert (a != 0) || (b != 0) into (a | b) != 0. */
> - if (code == TRUTH_OR_EXPR
> + if ((code == TRUTH_OR_EXPR || code == BIT_IOR_EXPR)
> && lcode == NE_EXPR && integer_zerop (lr_arg)
> && rcode == NE_EXPR && integer_zerop (rr_arg)
> && TREE_TYPE (ll_arg) == TREE_TYPE (rl_arg)
> @@ -5145,7 +5147,7 @@ fold_truthop (location_t loc, enum tree_
> build_int_cst (TREE_TYPE (ll_arg), 0));
>
> /* Convert (a == 0) && (b == 0) into (a | b) == 0. */
> - if (code == TRUTH_AND_EXPR
> + if ((code == TRUTH_AND_EXPR || code == BIT_AND_EXPR)
> && lcode == EQ_EXPR && integer_zerop (lr_arg)
> && rcode == EQ_EXPR && integer_zerop (rr_arg)
> && TREE_TYPE (ll_arg) == TREE_TYPE (rl_arg)
> @@ -5209,7 +5211,8 @@ fold_truthop (location_t loc, enum tree_
> fail. However, we can convert a one-bit comparison against zero into
> the opposite comparison against that bit being set in the field. */
>
> - wanted_code = (code == TRUTH_AND_EXPR ? EQ_EXPR : NE_EXPR);
> + wanted_code = ((code == TRUTH_AND_EXPR
> + || code == BIT_AND_EXPR) ? EQ_EXPR : NE_EXPR);
> if (lcode != wanted_code)
> {
> if (l_const && integer_zerop (l_const) && integer_pow2p (ll_mask))
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-07-13 10:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-13 7:34 [patch 2/8 tree-optimization]: Bitwise logic for fold_range_test and fold_truthop Kai Tietz
2011-07-13 10:28 ` Richard Guenther
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).