This is the mail archive of the
mailing list for the GCC project.
Re: Unable to match instruction pattern
- From: Richard Sandiford <rdsandiford at googlemail dot com>
- To: pshortis at dataworx dot com dot au
- Cc: gcc at gcc dot gnu dot org
- Date: Fri, 11 Apr 2014 19:21:24 +0100
- Subject: Re: Unable to match instruction pattern
- Authentication-results: sourceware.org; auth=none
- References: <534476C4 dot 3060809 at dataworx dot com dot au> <5345D557 dot 8010809 at davidgf dot es> <de7ea6ac386b258d36741347e2c14068 at dataworx dot com dot au>
> Found it ...
> I had
> (define_expand "zero_extendhisi2"
> (set (subreg:HI (match_operand:SI 0 "general_operand" "")0)
> (match_operand:HI 1 "general_operand" ""))
> (set (subreg:HI (match_dup 0)2)
> (const_int 0))
FWIW, in general you shouldn't use subregs in expanders, but instead use
[(set (match_operand:SI 0 "general_operand" "")
(zero_extend:SI (match_operand:HI 1 "general_operand" "")))]
emit_move_insn (gen_lowpart (HImode, operands), operands);
emit_move_insn (gen_highpart (HImode, operands), const0_rtx);
This allows MEMs to be simplified to smaller MEMs, which is preferable
to keeping them as SUBREGs. It also allows subregs of hard registers
to be simplified to simple REGs and handles constants correctly.
IMO SUBREGs of MEMs should go away. There's this strange convention
that (subreg (mem ...)) is treated as a register_operand before reload,
which is why:
if( !register_operand( operands, <MODE>mode )
&& !register_operand( operands, <MODE>mode ))
/* one of the operands must be in a register. */
operands = copy_to_mode_reg (<MODE>mode, operands);
wouldn't trigger for a move between a constant and a subreg of a MEM.
OTOH, you should be better off not defining the zero_extendhisi2 at all,
since IIRC the target-independent optabs code would generate the same
sequence for you.