This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Help needed with zero/sign extension
- From: Joern Rennecke <joern dot rennecke at embecosm dot com>
- To: Anthony Green <green at moxielogic dot com>
- Cc: GCC <gcc at gcc dot gnu dot org>
- Date: Wed, 2 Apr 2014 13:33:26 +0100
- Subject: Re: Help needed with zero/sign extension
- Authentication-results: sourceware.org; auth=none
- References: <87d2h0kk6x dot fsf at moxielogic dot com>
On 2 April 2014 13:08, Anthony Green <green@moxielogic.com> wrote:
> I though the answer was to simply add something like this...
>
> (define_insn "zero_extendqisi"
> [(set (match_operand:SI 0 "register_operand" "=r")
> (zero_extend:SI (match_operand:QI 1 "register_operand" "r")))]
> ""
> "; ZERO EXTEND (comment for debugging)")
That pattern is obviously not outputting valid code.
You should make this a define_insn_and_split, with an r/r alternative
that is split (after reload) as necesary into shifts, and an m/r alternative
that outputs a load. sprinkle with rtx_cost adjustments as necessary.
> But nothing changes in the example above.
LOAD_EXTEND_OP can also avoid some unnecesary expansions.
ALthough we still have a long-standing issue of unnecessary extensions for
narrow integer types passed in/out of functions, and loaded from volatile
memory.