[llvm-commits] [patch] Add relaxations for arithmetic instructions

Rafael EspĂ­ndola rafael.espindola at gmail.com
Thu Oct 21 16:59:33 PDT 2010


Some time ago I added a relaxation for ADD32ri8 which was needed for
x86. I decided to extend it to cover the remaining arithmetic
instructions. In doing so I found that the previous patch might have
introduced a bug as I am not sure exactly when a instruction
"MayNeedRelaxation" with RIP relative addressing.

The attached patch implements the remaining arithmetic instructions
and should fix ADD32ri8 being relaxed when using RIP relative
addressing.

Is the avoidance of relaxations for RIP addressing a MachO only thing?
With this patch we assemble

 zed:
_foo:
        nop
        cmpq $zed, _foo at GOTPCREL(%rip)

to
   0:	90                   	nop
   1:	48 83 3d f7 ff ff ff 	cmpq   $0x0,-0x9(%rip)        # 0 <_foo>
   8:	00

gnu as does
   0:	90                   	nop
   1:	48 81 3d f4 ff ff ff 	cmpq   $0x0,-0xc(%rip)        # 0 <_foo>
   8:	00 00 00 00

Changing the return from "hasExp && !hasRIP" to just "hasExp" makes us
produce the same output as gnu as, but breaks some of the MachO tests
in "make check-lit".

Cheers,
Rafael
-------------- next part --------------
A non-text attachment was scrubbed...
Name: arith.patch
Type: text/x-patch
Size: 4230 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20101021/65400583/attachment.bin>


More information about the llvm-commits mailing list