diff options
author | Richard Sandiford <richard.sandiford@arm.com> | 2024-06-18 12:22:31 +0100 |
---|---|---|
committer | Richard Sandiford <richard.sandiford@arm.com> | 2024-06-18 12:22:31 +0100 |
commit | 5f40d1c0cc6ce91ef28d326b8707b3f05e6f239c (patch) | |
tree | 106ff63d7ce4336bf8f41cb994f506af6b4d27d6 /gcc/explow.cc | |
parent | d4047da6a070175aae7121c739d1cad6b08ff4b2 (diff) | |
download | gcc-5f40d1c0cc6ce91ef28d326b8707b3f05e6f239c.zip gcc-5f40d1c0cc6ce91ef28d326b8707b3f05e6f239c.tar.gz gcc-5f40d1c0cc6ce91ef28d326b8707b3f05e6f239c.tar.bz2 |
Add force_lowpart_subreg
optabs had a local function called lowpart_subreg_maybe_copy
that is very similar to the lowpart version of force_subreg.
This patch adds a force_lowpart_subreg wrapper around
force_subreg and uses it in optabs.cc.
The only difference between the old and new functions is that
the old one asserted success while the new one doesn't.
It's common not to assert elsewhere when taking subregs;
normally a null result is enough.
Later patches will make more use of the new function.
gcc/
* explow.h (force_lowpart_subreg): Declare.
* explow.cc (force_lowpart_subreg): New function.
* optabs.cc (lowpart_subreg_maybe_copy): Delete.
(expand_absneg_bit): Use force_lowpart_subreg instead of
lowpart_subreg_maybe_copy.
(expand_copysign_bit): Likewise.
Diffstat (limited to 'gcc/explow.cc')
-rw-r--r-- | gcc/explow.cc | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/gcc/explow.cc b/gcc/explow.cc index bd93c87..2a91cf7 100644 --- a/gcc/explow.cc +++ b/gcc/explow.cc @@ -764,6 +764,20 @@ force_subreg (machine_mode outermode, rtx op, return res; } +/* Try to return an rvalue expression for the OUTERMODE lowpart of OP, + which has mode INNERMODE. Allow OP to be forced into a new register + if necessary. + + Return null on failure. */ + +rtx +force_lowpart_subreg (machine_mode outermode, rtx op, + machine_mode innermode) +{ + auto byte = subreg_lowpart_offset (outermode, innermode); + return force_subreg (outermode, op, innermode, byte); +} + /* If X is a memory ref, copy its contents to a new temp reg and return that reg. Otherwise, return X. */ |