diff options
author | Naveen H.S <Naveen.Hurugalawadi@caviumnetworks.com> | 2015-09-03 10:20:03 +0000 |
---|---|---|
committer | Naveen H.S <naveenh@gcc.gnu.org> | 2015-09-03 10:20:03 +0000 |
commit | 12085390166594050f02780cbd49a3967ecef882 (patch) | |
tree | 5015382f1627fbd7120f8d8be9eb4c48b0135017 /gcc/fold-const.c | |
parent | 27e2bd9f396088dc3642eb7d85eb424cc402c059 (diff) | |
download | gcc-12085390166594050f02780cbd49a3967ecef882.zip gcc-12085390166594050f02780cbd49a3967ecef882.tar.gz gcc-12085390166594050f02780cbd49a3967ecef882.tar.bz2 |
re PR tree-optimization/67351 (Missed optimisation on 64-bit field compared to 32-bit)
2015-09-03 Naveen H.S <Naveen.Hurugalawadi@caviumnetworks.com>
PR middle-end/67351
gcc/ChangeLog:
* fold-const.c (fold_binary_loc) : Move
Transform (x >> c) << c into x & (-1<<c) or
transform (x << c) >> c into x & ((unsigned)-1 >> c) for unsigned
types using simplify and match.
* match.pd (lshift (rshift @0 INTEGER_CST@1) @1) : New simplifier.
(rshift (lshift @0 INTEGER_CST@1) @1) : New Simplifier.
gcc/testsuite/ChangeLog:
* g++.dg/pr66752-2.C: New test.
From-SVN: r227432
Diffstat (limited to 'gcc/fold-const.c')
-rw-r--r-- | gcc/fold-const.c | 26 |
1 files changed, 0 insertions, 26 deletions
diff --git a/gcc/fold-const.c b/gcc/fold-const.c index d478c4d..a79bfa7 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -10412,32 +10412,6 @@ fold_binary_loc (location_t loc, prec = element_precision (type); - /* Transform (x >> c) << c into x & (-1<<c), or transform (x << c) >> c - into x & ((unsigned)-1 >> c) for unsigned types. */ - if (((code == LSHIFT_EXPR && TREE_CODE (arg0) == RSHIFT_EXPR) - || (TYPE_UNSIGNED (type) - && code == RSHIFT_EXPR && TREE_CODE (arg0) == LSHIFT_EXPR)) - && tree_fits_uhwi_p (arg1) - && tree_to_uhwi (arg1) < prec - && tree_fits_uhwi_p (TREE_OPERAND (arg0, 1)) - && tree_to_uhwi (TREE_OPERAND (arg0, 1)) < prec) - { - HOST_WIDE_INT low0 = tree_to_uhwi (TREE_OPERAND (arg0, 1)); - HOST_WIDE_INT low1 = tree_to_uhwi (arg1); - tree lshift; - tree arg00; - - if (low0 == low1) - { - arg00 = fold_convert_loc (loc, type, TREE_OPERAND (arg0, 0)); - - lshift = build_minus_one_cst (type); - lshift = const_binop (code, lshift, arg1); - - return fold_build2_loc (loc, BIT_AND_EXPR, type, arg00, lshift); - } - } - /* If we have a rotate of a bit operation with the rotate count and the second operand of the bit operation both constant, permute the two operations. */ |