1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-22 04:22:57 +02:00
llvm-mirror/test/CodeGen/X86/sub.ll
Benjamin Kramer bfc2dfe3f7 Add a neat little two's complement hack for x86.
On x86 we can't encode an immediate LHS of a sub directly. If the RHS comes from a XOR with a constant we can
fold the negation into the xor and add one to the immediate of the sub. Then we can turn the sub into an add,
which can be commuted and encoded efficiently.

This code is generated for __builtin_clz and friends.

llvm-svn: 136167
2011-07-26 22:42:13 +00:00

12 lines
223 B
LLVM

; RUN: llc -march=x86 < sub.ll | FileCheck %s
define i32 @test1(i32 %x) {
%xor = xor i32 %x, 31
%sub = sub i32 32, %xor
ret i32 %sub
; CHECK: test1:
; CHECK: xorl $-32
; CHECK-NEXT: addl $33
; CHECK-NEXT: ret
}