This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Patch] PR67351 Implement << N & >> N optimizers
- From: Marc Glisse <marc dot glisse at inria dot fr>
- To: "Hurugalawadi, Naveen" <Naveen dot Hurugalawadi at caviumnetworks dot com>
- Cc: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>, Richard Biener <richard dot guenther at gmail dot com>, "Pinski, Andrew" <Andrew dot Pinski at caviumnetworks dot com>, "ubizjak at gmail dot com" <ubizjak at gmail dot com>
- Date: Wed, 2 Sep 2015 13:18:10 +0200 (CEST)
- Subject: Re: [Patch] PR67351 Implement << N & >> N optimizers
- Authentication-results: sourceware.org; auth=none
- References: <SN2PR0701MB10245B423874D1D4C9B93F9F8E6A0 at SN2PR0701MB1024 dot namprd07 dot prod dot outlook dot com>
- Reply-to: gcc-patches at gcc dot gnu dot org
+/* Optimize (x >> c) << c into x & (-1<<c). */
+(simplify
+ (lshift (rshift @0 INTEGER_CST@1) @1)
+ (if (tree_fits_uhwi_p (@1)
+ && tree_to_uhwi (@1) < TYPE_PRECISION (type))
+ (bit_and @0 (lshift { build_minus_one_cst (type); } @1))))
It looks like vectors might match, so please use element_precision instead
of TYPE_PRECISION, as in the fold-const.c code you are converting from.
--
Marc Glisse