This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] PR middle-end/21137: Folding if (((int)x >> 31) & 64) into if ((int)x < 0)


The following patch is an attempt to finally fully close PR middle-end/21137.
As explained in the PR, my original patch from 2006 didn't handle the case
where there's a sign preserving NOP in the tree.  Easily fixed by calling
tree_strip_nop_conversions at the appropriate point in fold-const.c.
Most of this patch is the resulting re-indentation.

Test on x86_64-pc-linux-gnu with "make bootstrap" and "make check" with no regressions.

Ok for mainline? 

2016-08-05  Roger Sayle  <roger@nextmovesoftware.com>

        PR middle-end/21137
        * fold-const.c (fold_binary_loc) <EQ_EXPR>: Allow transformations of
        ((T)(X>>C1)&C2) eq/ne 0 when the cast (T) is a sign preserving NOP by
        calling tree_strip_nop_conversions.

        * gcc.dg/fold-eqandshift-4.c: New test case.


Roger
--
Roger Sayle, Ph.D.
CEO and founder
NextMove Software Limited
Registered in England No. 07588305
Registered Office: Innovation Centre (Unit 23), Cambridge Science Park, Cambridge CB4 0EY

Attachment: patcha.txt
Description: Text document

Attachment: fold-eqandshift-4.c
Description: Binary data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]