2011-03-16 14:52:51 +01:00
|
|
|
; RUN: llc < %s -mtriple=x86_64-linux | FileCheck %s -check-prefix=X86-64
|
|
|
|
; RUN: llc < %s -mtriple=x86_64-win32 | FileCheck %s -check-prefix=WIN64
|
2010-04-28 10:30:49 +02:00
|
|
|
; RUN: llc < %s -march=x86 | FileCheck %s -check-prefix=X86-32
|
Implement x86 h-register extract support.
- Add patterns for h-register extract, which avoids a shift and mask,
and in some cases a temporary register.
- Add address-mode matching for turning (X>>(8-n))&(255<<n), where
n is a valid address-mode scale value, into an h-register extract
and a scaled-offset address.
- Replace X86's MOV32to32_ and related instructions with the new
target-independent COPY_TO_SUBREG instruction.
On x86-64 there are complicated constraints on h registers, and
CodeGen doesn't currently provide a high-level way to express all of them,
so they are handled with a bunch of special code. This code currently only
supports extracts where the result is used by a zero-extend or a store,
though these are fairly common.
These transformations are not always beneficial; since there are only
4 h registers, they sometimes require extra move instructions, and
this sometimes increases register pressure because it can force out
values that would otherwise be in one of those registers. However,
this appears to be relatively uncommon.
llvm-svn: 68962
2009-04-13 18:09:41 +02:00
|
|
|
|
|
|
|
; Use h registers. On x86-64, codegen doesn't support general allocation
|
|
|
|
; of h registers yet, due to x86 encoding complications.
|
|
|
|
|
|
|
|
define void @bar64(i64 inreg %x, i8* inreg %p) nounwind {
|
2013-07-14 08:24:09 +02:00
|
|
|
; X86-64-LABEL: bar64:
|
2010-04-28 10:30:49 +02:00
|
|
|
; X86-64: shrq $8, %rdi
|
|
|
|
; X86-64: incb %dil
|
|
|
|
|
2011-03-16 14:52:51 +01:00
|
|
|
; See FIXME: on regclass GR8.
|
|
|
|
; It could be optimally transformed like; incb %ch; movb %ch, (%rdx)
|
2013-07-14 08:24:09 +02:00
|
|
|
; WIN64-LABEL: bar64:
|
2011-03-16 14:52:51 +01:00
|
|
|
; WIN64: shrq $8, %rcx
|
|
|
|
; WIN64: incb %cl
|
|
|
|
|
2013-07-14 08:24:09 +02:00
|
|
|
; X86-32-LABEL: bar64:
|
2010-04-28 10:30:49 +02:00
|
|
|
; X86-32: incb %ah
|
Implement x86 h-register extract support.
- Add patterns for h-register extract, which avoids a shift and mask,
and in some cases a temporary register.
- Add address-mode matching for turning (X>>(8-n))&(255<<n), where
n is a valid address-mode scale value, into an h-register extract
and a scaled-offset address.
- Replace X86's MOV32to32_ and related instructions with the new
target-independent COPY_TO_SUBREG instruction.
On x86-64 there are complicated constraints on h registers, and
CodeGen doesn't currently provide a high-level way to express all of them,
so they are handled with a bunch of special code. This code currently only
supports extracts where the result is used by a zero-extend or a store,
though these are fairly common.
These transformations are not always beneficial; since there are only
4 h registers, they sometimes require extra move instructions, and
this sometimes increases register pressure because it can force out
values that would otherwise be in one of those registers. However,
this appears to be relatively uncommon.
llvm-svn: 68962
2009-04-13 18:09:41 +02:00
|
|
|
%t0 = lshr i64 %x, 8
|
|
|
|
%t1 = trunc i64 %t0 to i8
|
|
|
|
%t2 = add i8 %t1, 1
|
|
|
|
store i8 %t2, i8* %p
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
define void @bar32(i32 inreg %x, i8* inreg %p) nounwind {
|
2013-07-14 08:24:09 +02:00
|
|
|
; X86-64-LABEL: bar32:
|
2010-04-28 10:30:49 +02:00
|
|
|
; X86-64: shrl $8, %edi
|
|
|
|
; X86-64: incb %dil
|
|
|
|
|
2013-07-14 08:24:09 +02:00
|
|
|
; WIN64-LABEL: bar32:
|
2011-03-16 14:52:51 +01:00
|
|
|
; WIN64: shrl $8, %ecx
|
|
|
|
; WIN64: incb %cl
|
|
|
|
|
2013-07-14 08:24:09 +02:00
|
|
|
; X86-32-LABEL: bar32:
|
2010-04-28 10:30:49 +02:00
|
|
|
; X86-32: incb %ah
|
Implement x86 h-register extract support.
- Add patterns for h-register extract, which avoids a shift and mask,
and in some cases a temporary register.
- Add address-mode matching for turning (X>>(8-n))&(255<<n), where
n is a valid address-mode scale value, into an h-register extract
and a scaled-offset address.
- Replace X86's MOV32to32_ and related instructions with the new
target-independent COPY_TO_SUBREG instruction.
On x86-64 there are complicated constraints on h registers, and
CodeGen doesn't currently provide a high-level way to express all of them,
so they are handled with a bunch of special code. This code currently only
supports extracts where the result is used by a zero-extend or a store,
though these are fairly common.
These transformations are not always beneficial; since there are only
4 h registers, they sometimes require extra move instructions, and
this sometimes increases register pressure because it can force out
values that would otherwise be in one of those registers. However,
this appears to be relatively uncommon.
llvm-svn: 68962
2009-04-13 18:09:41 +02:00
|
|
|
%t0 = lshr i32 %x, 8
|
|
|
|
%t1 = trunc i32 %t0 to i8
|
|
|
|
%t2 = add i8 %t1, 1
|
|
|
|
store i8 %t2, i8* %p
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
define void @bar16(i16 inreg %x, i8* inreg %p) nounwind {
|
2013-07-14 08:24:09 +02:00
|
|
|
; X86-64-LABEL: bar16:
|
2010-04-28 10:30:49 +02:00
|
|
|
; X86-64: shrl $8, %edi
|
|
|
|
; X86-64: incb %dil
|
|
|
|
|
2013-07-14 08:24:09 +02:00
|
|
|
; WIN64-LABEL: bar16:
|
2011-03-16 14:52:51 +01:00
|
|
|
; WIN64: shrl $8, %ecx
|
|
|
|
; WIN64: incb %cl
|
|
|
|
|
2013-07-14 08:24:09 +02:00
|
|
|
; X86-32-LABEL: bar16:
|
2010-04-28 10:30:49 +02:00
|
|
|
; X86-32: incb %ah
|
Implement x86 h-register extract support.
- Add patterns for h-register extract, which avoids a shift and mask,
and in some cases a temporary register.
- Add address-mode matching for turning (X>>(8-n))&(255<<n), where
n is a valid address-mode scale value, into an h-register extract
and a scaled-offset address.
- Replace X86's MOV32to32_ and related instructions with the new
target-independent COPY_TO_SUBREG instruction.
On x86-64 there are complicated constraints on h registers, and
CodeGen doesn't currently provide a high-level way to express all of them,
so they are handled with a bunch of special code. This code currently only
supports extracts where the result is used by a zero-extend or a store,
though these are fairly common.
These transformations are not always beneficial; since there are only
4 h registers, they sometimes require extra move instructions, and
this sometimes increases register pressure because it can force out
values that would otherwise be in one of those registers. However,
this appears to be relatively uncommon.
llvm-svn: 68962
2009-04-13 18:09:41 +02:00
|
|
|
%t0 = lshr i16 %x, 8
|
|
|
|
%t1 = trunc i16 %t0 to i8
|
|
|
|
%t2 = add i8 %t1, 1
|
|
|
|
store i8 %t2, i8* %p
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
define i64 @qux64(i64 inreg %x) nounwind {
|
2013-07-14 08:24:09 +02:00
|
|
|
; X86-64-LABEL: qux64:
|
2010-04-28 10:30:49 +02:00
|
|
|
; X86-64: movq %rdi, %rax
|
|
|
|
; X86-64: movzbl %ah, %eax
|
|
|
|
|
2013-07-14 08:24:09 +02:00
|
|
|
; WIN64-LABEL: qux64:
|
2011-03-16 14:52:51 +01:00
|
|
|
; WIN64: movzbl %ch, %eax
|
|
|
|
|
2013-07-14 08:24:09 +02:00
|
|
|
; X86-32-LABEL: qux64:
|
2011-04-14 03:46:37 +02:00
|
|
|
; X86-32: movzbl %ah, %eax
|
Implement x86 h-register extract support.
- Add patterns for h-register extract, which avoids a shift and mask,
and in some cases a temporary register.
- Add address-mode matching for turning (X>>(8-n))&(255<<n), where
n is a valid address-mode scale value, into an h-register extract
and a scaled-offset address.
- Replace X86's MOV32to32_ and related instructions with the new
target-independent COPY_TO_SUBREG instruction.
On x86-64 there are complicated constraints on h registers, and
CodeGen doesn't currently provide a high-level way to express all of them,
so they are handled with a bunch of special code. This code currently only
supports extracts where the result is used by a zero-extend or a store,
though these are fairly common.
These transformations are not always beneficial; since there are only
4 h registers, they sometimes require extra move instructions, and
this sometimes increases register pressure because it can force out
values that would otherwise be in one of those registers. However,
this appears to be relatively uncommon.
llvm-svn: 68962
2009-04-13 18:09:41 +02:00
|
|
|
%t0 = lshr i64 %x, 8
|
|
|
|
%t1 = and i64 %t0, 255
|
|
|
|
ret i64 %t1
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @qux32(i32 inreg %x) nounwind {
|
2013-07-14 08:24:09 +02:00
|
|
|
; X86-64-LABEL: qux32:
|
2010-04-28 10:30:49 +02:00
|
|
|
; X86-64: movl %edi, %eax
|
|
|
|
; X86-64: movzbl %ah, %eax
|
|
|
|
|
2013-07-14 08:24:09 +02:00
|
|
|
; WIN64-LABEL: qux32:
|
2011-03-16 14:52:51 +01:00
|
|
|
; WIN64: movzbl %ch, %eax
|
|
|
|
|
2013-07-14 08:24:09 +02:00
|
|
|
; X86-32-LABEL: qux32:
|
2011-04-14 03:46:37 +02:00
|
|
|
; X86-32: movzbl %ah, %eax
|
Implement x86 h-register extract support.
- Add patterns for h-register extract, which avoids a shift and mask,
and in some cases a temporary register.
- Add address-mode matching for turning (X>>(8-n))&(255<<n), where
n is a valid address-mode scale value, into an h-register extract
and a scaled-offset address.
- Replace X86's MOV32to32_ and related instructions with the new
target-independent COPY_TO_SUBREG instruction.
On x86-64 there are complicated constraints on h registers, and
CodeGen doesn't currently provide a high-level way to express all of them,
so they are handled with a bunch of special code. This code currently only
supports extracts where the result is used by a zero-extend or a store,
though these are fairly common.
These transformations are not always beneficial; since there are only
4 h registers, they sometimes require extra move instructions, and
this sometimes increases register pressure because it can force out
values that would otherwise be in one of those registers. However,
this appears to be relatively uncommon.
llvm-svn: 68962
2009-04-13 18:09:41 +02:00
|
|
|
%t0 = lshr i32 %x, 8
|
|
|
|
%t1 = and i32 %t0, 255
|
|
|
|
ret i32 %t1
|
|
|
|
}
|
|
|
|
|
|
|
|
define i16 @qux16(i16 inreg %x) nounwind {
|
2013-07-14 08:24:09 +02:00
|
|
|
; X86-64-LABEL: qux16:
|
2010-04-28 10:30:49 +02:00
|
|
|
; X86-64: movl %edi, %eax
|
|
|
|
; X86-64: movzbl %ah, %eax
|
|
|
|
|
2013-07-14 08:24:09 +02:00
|
|
|
; WIN64-LABEL: qux16:
|
2011-03-16 14:52:51 +01:00
|
|
|
; WIN64: movzbl %ch, %eax
|
|
|
|
|
2013-07-14 08:24:09 +02:00
|
|
|
; X86-32-LABEL: qux16:
|
2011-04-14 03:46:37 +02:00
|
|
|
; X86-32: movzbl %ah, %eax
|
Implement x86 h-register extract support.
- Add patterns for h-register extract, which avoids a shift and mask,
and in some cases a temporary register.
- Add address-mode matching for turning (X>>(8-n))&(255<<n), where
n is a valid address-mode scale value, into an h-register extract
and a scaled-offset address.
- Replace X86's MOV32to32_ and related instructions with the new
target-independent COPY_TO_SUBREG instruction.
On x86-64 there are complicated constraints on h registers, and
CodeGen doesn't currently provide a high-level way to express all of them,
so they are handled with a bunch of special code. This code currently only
supports extracts where the result is used by a zero-extend or a store,
though these are fairly common.
These transformations are not always beneficial; since there are only
4 h registers, they sometimes require extra move instructions, and
this sometimes increases register pressure because it can force out
values that would otherwise be in one of those registers. However,
this appears to be relatively uncommon.
llvm-svn: 68962
2009-04-13 18:09:41 +02:00
|
|
|
%t0 = lshr i16 %x, 8
|
|
|
|
ret i16 %t0
|
|
|
|
}
|