diff options
author | Roger Sayle <roger@nextmovesoftware.com> | 2021-08-31 11:45:07 +0100 |
---|---|---|
committer | Roger Sayle <roger@nextmovesoftware.com> | 2021-08-31 11:45:07 +0100 |
commit | cad36f38576a6a781e3c62ab061c68f5b8dab13a (patch) | |
tree | 087a30904a1919172629cfb4f6057c4313ec51d9 /gcc/fortran/openmp.c | |
parent | 0960d937d9bee3c831d0b64a9c828c263a58ff89 (diff) | |
download | gcc-cad36f38576a6a781e3c62ab061c68f5b8dab13a.zip gcc-cad36f38576a6a781e3c62ab061c68f5b8dab13a.tar.gz gcc-cad36f38576a6a781e3c62ab061c68f5b8dab13a.tar.bz2 |
Preserve SUBREG_PROMOTED_VAR_P on (extend:HI (subreg/s:QI (reg:SI))).
SUBREG_PROMOTED_VAR_P is a mechanism for tracking that a partial subreg
is correctly zero-extended or sign-extended in the parent register. For
example, the RTL (subreg/s/v:QI (reg/v:SI 23 [ x ]) 0) indicates that the
byte x is zero extended in reg:SI 23, which is useful for optimization.
An example is that zero extending the above QImode value to HImode can
simply use a wider subreg, i.e. (subreg:HI (reg/v:SI 23 [ x ]) 0).
This patch addresses the oversight/missed optimization opportunity that
the new HImode subreg above should retain its SUBREG_PROMOTED_VAR_P
annotation as its value is guaranteed to be correctly extended in the
SImode parent. The code below to preserve SUBREG_PROMOTED_VAR_P is already
present in the middle-end (e.g. simplify-rtx.c:7232-7242) but missing
from one or two (precisely three) places that (accidentally) strip it.
Whilst there I also added another optimization. If we need to extend
the above QImode value beyond the SImode register holding it, say to
DImode, we can eliminate the SUBREG and simply extend from the SImode
register to DImode.
2021-08-31 Roger Sayle <roger@nextmovesoftware.com>
gcc/ChangeLog
* expr.c (convert_modes): Preserve SUBREG_PROMOTED_VAR_P when
creating a (wider) partial subreg from a SUBREG_PROMOTED_VAR_P
subreg.
* simplify-rtx.c (simplify_unary_operation_1) [SIGN_EXTEND]:
Likewise, preserve SUBREG_PROMOTED_VAR_P when creating a (wider)
partial subreg from a SUBREG_PROMOTED_VAR_P subreg. Generate
SIGN_EXTEND of the SUBREG_REG when a subreg would be paradoxical.
[ZERO_EXTEND]: Likewise, preserve SUBREG_PROMOTED_VAR_P when
creating a (wider) partial subreg from a SUBREG_PROMOTED_VAR_P
subreg. Generate ZERO_EXTEND of the SUBREG_REG when a subreg
would be paradoxical.
Diffstat (limited to 'gcc/fortran/openmp.c')
0 files changed, 0 insertions, 0 deletions