mirror of
https://github.com/RPCSX/llvm.git
synced 2025-01-12 23:40:54 +00:00
664a3a9314
xorl + setcc is generally the preferred sequence due to the partial register stall setcc + movzbl suffers from. As a bonus, it also encodes one byte smaller. This fixes PR28146. The original commit tried inserting an 8bit-subreg into a GR32 (not GR32_ABCD) which was not appreciated by fast regalloc on 32-bit. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274802 91177308-0d34-0410-b5e6-96231b3b80d8
139 lines
3.2 KiB
LLVM
139 lines
3.2 KiB
LLVM
; RUN: llc < %s -mtriple=i686-unknown-linux-gnu -fixup-byte-word-insts=0 | \
|
|
; RUN: FileCheck -check-prefix=CHECK -check-prefix=BWOFF %s
|
|
; RUN: llc < %s -mtriple=i686-unknown-linux-gnu -fixup-byte-word-insts=1 | \
|
|
; RUN: FileCheck -check-prefix=CHECK -check-prefix=BWON %s
|
|
; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -fixup-byte-word-insts=0 | \
|
|
; RUN: FileCheck -check-prefix=CHECK -check-prefix=BWOFF %s
|
|
; RUN: llc < %s -mtriple=i686-unknown-linux-gnu -fixup-byte-word-insts=1 | \
|
|
; RUN: FileCheck -check-prefix=CHECK -check-prefix=BWON %s
|
|
; RUN: llc < %s -mtriple=x86_64-apple-darwin -fixup-byte-word-insts=0 | \
|
|
; RUN: FileCheck -check-prefix=DARWIN -check-prefix=DARWIN-BWOFF %s
|
|
; RUN: llc < %s -mtriple=x86_64-apple-darwin -fixup-byte-word-insts=1 | \
|
|
; RUN: FileCheck -check-prefix=DARWIN -check-prefix=DARWIN-BWON %s
|
|
|
|
|
|
@x = common global i32 0, align 4
|
|
|
|
define zeroext i1 @unsigned_i1() {
|
|
entry:
|
|
%0 = load i32, i32* @x
|
|
%cmp = icmp eq i32 %0, 42
|
|
ret i1 %cmp
|
|
|
|
; Unsigned i1 return values are not extended.
|
|
; CHECK-LABEL: unsigned_i1:
|
|
; CHECK: cmp
|
|
; CHECK-NEXT: sete
|
|
; CHECK-NEXT: ret
|
|
}
|
|
|
|
define zeroext i8 @unsigned_i8() {
|
|
entry:
|
|
%0 = load i32, i32* @x
|
|
%cmp = icmp eq i32 %0, 42
|
|
%retval = zext i1 %cmp to i8
|
|
ret i8 %retval
|
|
|
|
; Unsigned i8 return values are not extended.
|
|
; CHECK-LABEL: unsigned_i8:
|
|
; CHECK: cmp
|
|
; CHECK-NEXT: sete
|
|
; CHECK-NEXT: ret
|
|
|
|
; Except on Darwin, for legacy reasons.
|
|
; DARWIN-LABEL: unsigned_i8:
|
|
; DARWIN: xorl
|
|
; DARWIN-NEXT: cmp
|
|
; DARWIN-NEXT: sete
|
|
; DARWIN-NEXT: ret
|
|
}
|
|
|
|
define signext i8 @signed_i8() {
|
|
entry:
|
|
%0 = load i32, i32* @x
|
|
%cmp = icmp eq i32 %0, 42
|
|
%retval = zext i1 %cmp to i8
|
|
ret i8 %retval
|
|
|
|
; Signed i8 return values are not extended.
|
|
; CHECK-LABEL: signed_i8:
|
|
; CHECK: cmp
|
|
; CHECK-NEXT: sete
|
|
; CHECK-NEXT: ret
|
|
|
|
; Except on Darwin, for legacy reasons.
|
|
; DARWIN-LABEL: signed_i8:
|
|
; DARWIN: xorl
|
|
; DARWIN-NEXT: cmp
|
|
; DARWIN-NEXT: sete
|
|
; DARWIN-NEXT: ret
|
|
}
|
|
|
|
@a = common global i16 0
|
|
@b = common global i16 0
|
|
define zeroext i16 @unsigned_i16() {
|
|
entry:
|
|
%0 = load i16, i16* @a
|
|
%1 = load i16, i16* @b
|
|
%add = add i16 %1, %0
|
|
ret i16 %add
|
|
|
|
; i16 return values are not extended.
|
|
; CHECK-LABEL: unsigned_i16:
|
|
; BWOFF: movw
|
|
; BWON: movzwl
|
|
; CHECK-NEXT: addw
|
|
; CHECK-NEXT: ret
|
|
|
|
; Except on Darwin, for legacy reasons.
|
|
; DARWIN-LABEL: unsigned_i16:
|
|
; DARWIN-BWOFF: movw
|
|
; DARWIN-BWON: movzwl
|
|
; DARWIN-NEXT: addw
|
|
; DARWIN-NEXT: movzwl
|
|
; DARWIN-NEXT: ret
|
|
}
|
|
|
|
|
|
define i32 @use_i1() {
|
|
entry:
|
|
%0 = call i1 @unsigned_i1();
|
|
%1 = zext i1 %0 to i32
|
|
ret i32 %1
|
|
|
|
; The high 24 bits of %eax from a function returning i1 are undefined.
|
|
; CHECK-LABEL: use_i1:
|
|
; CHECK: call
|
|
; CHECK-NEXT: movzbl
|
|
; CHECK-NEXT: {{pop|add}}
|
|
; CHECK-NEXT: ret
|
|
}
|
|
|
|
define i32 @use_i8() {
|
|
entry:
|
|
%0 = call i8 @unsigned_i8();
|
|
%1 = zext i8 %0 to i32
|
|
ret i32 %1
|
|
|
|
; The high 24 bits of %eax from a function returning i8 are undefined.
|
|
; CHECK-LABEL: use_i8:
|
|
; CHECK: call
|
|
; CHECK-NEXT: movzbl
|
|
; CHECK-NEXT: {{pop|add}}
|
|
; CHECK-NEXT: ret
|
|
}
|
|
|
|
define i32 @use_i16() {
|
|
entry:
|
|
%0 = call i16 @unsigned_i16();
|
|
%1 = zext i16 %0 to i32
|
|
ret i32 %1
|
|
|
|
; The high 16 bits of %eax from a function returning i16 are undefined.
|
|
; CHECK-LABEL: use_i16:
|
|
; CHECK: call
|
|
; CHECK-NEXT: movzwl
|
|
; CHECK-NEXT: {{pop|add}}
|
|
; CHECK-NEXT: ret
|
|
}
|