]> git.ipfire.org Git - thirdparty/gcc.git/commit
Replace a HWI_COMPUTABLE_MODE_P with wide-int in simplify-rtx.cc.
authorRoger Sayle <roger@nextmovesoftware.com>
Tue, 30 May 2023 13:46:45 +0000 (14:46 +0100)
committerRoger Sayle <roger@nextmovesoftware.com>
Tue, 30 May 2023 13:46:45 +0000 (14:46 +0100)
commit2a941f9f824b64ea8b42c885746fbc5f5321589d
treef552e49ea73d6defd97c23043793647f413b70c1
parent69185294f322dd53d4e1592115014c5488302e2e
Replace a HWI_COMPUTABLE_MODE_P with wide-int in simplify-rtx.cc.

This patch enhances one of the optimizations in simplify_binary_operation_1
to allow it to simplify RTL expressions in modes wider than HOST_WIDE_INT
by replacing a use of HWI_COMPUTABLE_MODE_P and UINTVAL with wide_int.

The motivating example is a pending x86_64 backend patch that produces
the following RTL in combine:

(and:TI (zero_extend:TI (reg:DI 89))
        (const_wide_int 0x0ffffffffffffffff))

where the AND is redundant, as the mask, ~0LL, is DImode's MODE_MASK.
There's already an optimization that catches this for narrower modes,
transforming (and:HI (zero_extend:HI (reg:QI x)) (const_int 0xff))
into (zero_extend:HI (reg:QI x)), but this currently only handles
CONST_INT not CONST_WIDE_INT.  Fixed by upgrading this transformation
to use wide_int, specifically rtx_mode_t and wi::mask.

2023-05-30  Roger Sayle  <roger@nextmovesoftware.com>

gcc/ChangeLog
* simplify-rtx.cc (simplify_binary_operation_1) <AND>: Use wide-int
instead of HWI_COMPUTABLE_MODE_P and UINTVAL in transformation of
(and (extend X) C) as (zero_extend (and X C)), to also optimize
modes wider than HOST_WIDE_INT.
gcc/simplify-rtx.cc