This is the mail archive of the
`gcc@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] |

*From*: Jeff Law <law at redhat dot com>*To*: Kyrill Tkachov <kyrylo dot tkachov at foss dot arm dot com>, "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>*Date*: Fri, 26 Feb 2016 14:24:49 -0700*Subject*: Re: Validity of SUBREG+AND-imm transformations*Authentication-results*: sourceware.org; auth=none*References*: <56D055C6 dot 6040800 at foss dot arm dot com>

On 02/26/2016 06:40 AM, Kyrill Tkachov wrote:

Hi all, I'm looking at a case where some RTL passes create an RTL expression of the form: (subreg:QI (and:SI (reg:SI x1) (const_int 31)) 0) which I'd like to simplify to: (and:QI (subreg:QI (reg:SI x1) 0) (const_int 31))

(subreg:SI (whatever:QI)) vs {zero,sign}_extend:SI (whatever:QI)) vs (and:SI (subreg:SI (whatever:QI) (const_int 0x255)))

The second & 3rd variants crisply define the upper bits.

It's easy enough to express in RTL but I'm trying to convince myself on its validity. I know there are some subtle points in this area. combine_simplify_rtx in combine.c has a comment: /* Note that we cannot do any narrowing for non-constants since we might have been counting on using the fact that some bits were zero. We now do this in the SET. */

The code used to do this: - if (GET_MODE_CLASS (mode) == MODE_INT - && GET_MODE_CLASS (GET_MODE (SUBREG_REG (x))) == MODE_INT

- && subreg_lowpart_p (x)) - return force_to_mode (SUBREG_REG (x), mode, GET_MODE_MASK (mode), - NULL_RTX, 0);

and if I try to implement this transformation in simplify_subreg from simplify-rtx.c I get some cases where combine goes into an infinite recursion in simplify_comparison because it tries to do: /* If this is (and:M1 (subreg:M1 X:M2 0) (const_int C1)) where C1 fits in both M1 and M2 and the SUBREG is either paradoxical or represents the low part, permute the SUBREG and the AND and try again. */

Performing this transformation would help a lot with recognition of some patterns that I'm working on, so would it be acceptable to teach combine or simplify-rtx to do this?

jeff

**Follow-Ups**:**Re: Validity of SUBREG+AND-imm transformations***From:*Kyrill Tkachov

**References**:**Validity of SUBREG+AND-imm transformations***From:*Kyrill Tkachov

Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|

Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |