> On 2 Mar 2017, at 11:34 AM, Andrew Waterman <
and...@sifive.com> wrote:
>
> gcc should be using mv to copy registers. Could you submit a bug
> report & test case to the riscv-gcc github issue tracker if it fails
> to do so?
OK. It is just eyeballing asm. I’m not sure what C program creates mv.
Definitely seeing “add rd, zero, rs2” pattern for mv versus “addi rd, rs1, 0”.
$ ls -l `which riscv64-unknown-elf-gcc`
-rwxr-xr-x 2 mclark mclark 5181232 Feb 15 19:44 /opt/riscv/toolchain/bin/riscv64-unknown-elf-gcc
$ rv-bin dump -a linux-4.6.2/vmlinux | grep "add " | grep zero | head
800000d0: 892a add s2, zero, a0
800000d2: 8b2e add s6, zero, a1
800000f4: 854a add a0, zero, s2
80000104: 854a add a0, zero, s2
8000010e: 855a add a0, zero, s6
80000114: 85ca add a1, zero, s2
800001b2: 892a add s2, zero, a0
800001b6: 85aa add a1, zero, a0
800001c2: 85ce add a1, zero, s3
800001c4: 8556 add a0, zero, s5
> I don't think we need a new pseudo-op to zero a register, as li rd, 0
> gets the point across fine.
li rd, 0 is okay.
The point was more that the emitted opcode for the 0 case could be different so it might be useful in a translation layer. e.g. a pseudo mapping vs a special case based on the immediate value. np.