path64/compiler — Issue #127: Integer type conversion to smaller size adds bogus instruction
Author: juikim
Created: 2011-11-10 21:37:28+00:00
State: open

For example, int foo(long a) { return (a); } inserts bogus movslq instruction.

With -O0:

pushq %rbp
movq %rsp,%rbp
addq $-32,%rsp
movq %rdi,-16(%rbp)
movq -16(%rbp),%rax
movslq %eax,%rax
leave
ret

With -O3:

movslq %edi,%rax
ret

Both GCC and Clang (-O3) produce expected result, i.e., movl %edi, %eax; ret. The following ops look suspicious to me:

I8I8LDID 41 <1,5,.preg_I8> T<5,.predef_I8,8> # a
I8CVTL 32
I8STID 1 <1,5,.preg_I8> T<5,.predef_I8,8> # $r1
preg 1 maps to tn 1
expand OPC_I8CVTL: TN1(%rax) :- TN149 (0x20)
into [ 0, 0] TN1(%rax) :- movslq TN149 ;