diff options
author | Naveen H.S <Naveen.Hurugalawadi@caviumnetworks.com> | 2015-07-24 04:47:48 +0000 |
---|---|---|
committer | Naveen H.S <naveenh@gcc.gnu.org> | 2015-07-24 04:47:48 +0000 |
commit | 887ab609652894b410854aadf593526e96c735b2 (patch) | |
tree | a5cac4f24596afe32c7645d5f8e071b7176ef2f6 /gcc | |
parent | 390875e69414e413076e9dad99dfab945f986eab (diff) | |
download | gcc-887ab609652894b410854aadf593526e96c735b2.zip gcc-887ab609652894b410854aadf593526e96c735b2.tar.gz gcc-887ab609652894b410854aadf593526e96c735b2.tar.bz2 |
re PR middle-end/25529 ((unsigned * 2)/2 is not changed into unsigned &0x7FFFFFFF)
PR middle-end/25529
2015-07-24 Naveen H.S <Naveen.Hurugalawadi@caviumnetworks.com>
gcc/testsuite/ChangeLog:
* gcc.dg/pr25529.c: New test.
gcc/ChangeLog:
* match.pd (trunc_div (mult @0 integer_pow2p@1) @1) : New simplifier.
From-SVN: r226136
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/match.pd | 11 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr25529.c | 11 |
4 files changed, 31 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 211f82b..aca1f82 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2015-07-24 Naveen H.S <Naveen.Hurugalawadi@caviumnetworks.com> + + PR middle-end/25529 + * match.pd (trunc_div (mult @0 integer_pow2p@1) @1) : New simplifier. + 2015-07-23 Kugan Vivekanandarajah <kuganv@linaro.org> * config/arm/arm.c (arm_emit_movpair): Add REG_EQUAL notes to diff --git a/gcc/match.pd b/gcc/match.pd index 9c181f6..cc30897 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -29,7 +29,8 @@ along with GCC; see the file COPYING3. If not see integer_each_onep integer_truep real_zerop real_onep real_minus_onep CONSTANT_CLASS_P - tree_expr_nonnegative_p) + tree_expr_nonnegative_p + integer_pow2p) /* Operator lists. */ (define_operator_list tcc_comparison @@ -280,6 +281,14 @@ along with GCC; see the file COPYING3. If not see && integer_pow2p (@2) && tree_int_cst_sgn (@2) > 0) (bit_and @0 (convert (minus @1 { build_int_cst (TREE_TYPE (@1), 1); })))))) +/* Simplify (unsigned t * 2)/2 -> unsigned t & 0x7FFFFFFF. */ +(simplify + (trunc_div (mult @0 integer_pow2p@1) @1) + (if (TYPE_UNSIGNED (TREE_TYPE (@0))) + (bit_and @0 { wide_int_to_tree + (type, wi::mask (TYPE_PRECISION (type) - wi::exact_log2 (@1), + false, TYPE_PRECISION (type))); }))) + /* X % Y is smaller than Y. */ (for cmp (lt ge) (simplify diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 81d09f6..9adf876 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-07-24 Naveen H.S <Naveen.Hurugalawadi@caviumnetworks.com> + + PR middle-end/25529 + * gcc.dg/pr25529.c: New test. + 2015-07-23 Kugan Vivekanandarajah <kuganv@linaro.org> * gcc.target/arm/reg_equal_test.c: New test. diff --git a/gcc/testsuite/gcc.dg/pr25529.c b/gcc/testsuite/gcc.dg/pr25529.c new file mode 100644 index 0000000..336d93b --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr25529.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-require-effective-target int32 } */ + +int +f (unsigned t) +{ + return (t * 2) / 2; +} + +/* { dg-final { scan-tree-dump "\& 2147483647" "optimized" } } */ |