On Tue, Sep 1, 2015 at 10:57 AM, Hurugalawadi, Naveen <naveen.hurugalaw...@caviumnetworks.com> wrote: > Hi, > > Please find attached the patch "pr67351.patch" that implements the > pattern << N & >> N optimizers.
+ (bit_and @0 (lshift { build_minus_one_cst (type); } @1)))) please use (bit_and @0 { wide_int_to_tree (type, wi::lshift (-1, @1)); }) and wi::arshift for the other pattern. It should then be possible to drop the tree_fits_uhwi_p tests and replace the precision test with wi::ltu_p (@1, TYPE_PRECISION (type)). Ok with these changes. Thanks, Richard. > > Please review and let me know if its okay. > > Regression tested on AARH64 and x86_64. > > Thanks, > Naveen > > 2015-09-01 Naveen H.S <naveen.hurugalaw...@caviumnetworks.com> > > gcc/ChangeLog: > > PR middle-end/67351 > * 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: > > PR middle-end/67351 > * g++.dg/pr66752-2.C: New test.