diff mbox

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

Message ID 272919660.873703.1309456866041.JavaMail.root@zmail06.collab.prod.int.phx2.redhat.com
State New
Headers show

Commit Message

Kai Tietz June 30, 2011, 6:01 p.m. UTC
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

Comments

Richard Biener July 1, 2011, 7:59 a.m. UTC | #1
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;
>
diff mbox

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;