Patchwork [tree-optimization] : Fix typo in X bitwise-binary-op CST

login
register
mail settings
Submitter Kai Tietz
Date June 30, 2011, 6:01 p.m.
Message ID <272919660.873703.1309456866041.JavaMail.root@zmail06.collab.prod.int.phx2.redhat.com>
Download mbox | patch
Permalink /patch/102798/
State New
Headers show

Comments

Kai Tietz - June 30, 2011, 6:01 p.m.
Hello,

this patch fixes a typo in type-sinking for bitwise-binary operation X op CST.

ChangeLog gcc/

2011-06-30  Kai Tietz  <ktietz@redhat.com>

        * tree-ssa-forwprop.c (simplify_bitwise_binary): Fix typo.

ChangeLog gcc/testsuite

2011-06-30  Kai Tietz  <ktietz@redhat.com>

        * gcc.dg/tree-ssa/bitwise-sink.c: New test.

Bootstrapped and regression tested for all standard languages plus Ada and Obj-C++ on x86_64-pc-linux-gnu. Ok for apply?

Regards,
Kai
Richard Guenther - July 1, 2011, 7:59 a.m.
On Thu, Jun 30, 2011 at 8:01 PM, Kai Tietz <ktietz@redhat.com> wrote:
> Hello,
>
> this patch fixes a typo in type-sinking for bitwise-binary operation X op CST.
>
> ChangeLog gcc/
>
> 2011-06-30  Kai Tietz  <ktietz@redhat.com>
>
>        * tree-ssa-forwprop.c (simplify_bitwise_binary): Fix typo.
>
> ChangeLog gcc/testsuite
>
> 2011-06-30  Kai Tietz  <ktietz@redhat.com>
>
>        * gcc.dg/tree-ssa/bitwise-sink.c: New test.
>
> Bootstrapped and regression tested for all standard languages plus Ada and Obj-C++ on x86_64-pc-linux-gnu. Ok for apply?

Ok.

Thanks,
Richard.

> Regards,
> Kai
>
> Index: gcc-head/gcc/testsuite/gcc.dg/tree-ssa/bitwise-sink.c
> ===================================================================
> --- /dev/null
> +++ gcc-head/gcc/testsuite/gcc.dg/tree-ssa/bitwise-sink.c
> @@ -0,0 +1,11 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O2 -fdump-tree-optimized" } */
> +
> +int
> +foo (_Bool x)
> +{
> +  return (x ^ 1);
> +}
> +
> +/* { dg-final { scan-tree-dump-times "x\[^ \]* \\^ 1" 1 "optimized" } } */
> +/* { dg-final { cleanup-tree-dump "optimized" } } */
> Index: gcc-head/gcc/tree-ssa-forwprop.c
> ===================================================================
> --- gcc-head.orig/gcc/tree-ssa-forwprop.c
> +++ gcc-head/gcc/tree-ssa-forwprop.c
> @@ -1946,7 +1946,7 @@ simplify_bitwise_binary (gimple_stmt_ite
>   /* Try to fold (type) X op CST -> (type) (X op ((type-x) CST)).  */
>   if (TREE_CODE (arg2) == INTEGER_CST
>       && CONVERT_EXPR_CODE_P (def1_code)
> -      && INTEGRAL_TYPE_P (def1_arg1)
> +      && INTEGRAL_TYPE_P (TREE_TYPE (def1_arg1))
>       && int_fits_type_p (arg2, TREE_TYPE (def1_arg1)))
>     {
>       gimple newop;
>

Patch

Index: gcc-head/gcc/testsuite/gcc.dg/tree-ssa/bitwise-sink.c
===================================================================
--- /dev/null
+++ gcc-head/gcc/testsuite/gcc.dg/tree-ssa/bitwise-sink.c
@@ -0,0 +1,11 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+
+int
+foo (_Bool x)
+{
+  return (x ^ 1);
+}
+
+/* { dg-final { scan-tree-dump-times "x\[^ \]* \\^ 1" 1 "optimized" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
Index: gcc-head/gcc/tree-ssa-forwprop.c
===================================================================
--- gcc-head.orig/gcc/tree-ssa-forwprop.c
+++ gcc-head/gcc/tree-ssa-forwprop.c
@@ -1946,7 +1946,7 @@  simplify_bitwise_binary (gimple_stmt_ite
   /* Try to fold (type) X op CST -> (type) (X op ((type-x) CST)).  */
   if (TREE_CODE (arg2) == INTEGER_CST
       && CONVERT_EXPR_CODE_P (def1_code)
-      && INTEGRAL_TYPE_P (def1_arg1)
+      && INTEGRAL_TYPE_P (TREE_TYPE (def1_arg1))
       && int_fits_type_p (arg2, TREE_TYPE (def1_arg1)))
     {
       gimple newop;