2018-01-16 05:32:39 +08:00
|
|
|
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
|
|
|
|
; RUN: llc -mtriple=x86_64-unknown-unknown -show-mc-encoding < %s | FileCheck %s
|
2015-07-17 08:57:52 +08:00
|
|
|
|
2018-01-16 05:57:41 +08:00
|
|
|
; Test that the direct object emission selects the 'and' variant with 8-bit
|
2015-07-17 08:57:52 +08:00
|
|
|
; immediate.
|
|
|
|
; We used to get this wrong when using direct object emission, but not when
|
|
|
|
; reading assembly.
|
|
|
|
|
2018-01-16 05:32:39 +08:00
|
|
|
define void @f1() nounwind {
|
2015-07-17 08:57:52 +08:00
|
|
|
; CHECK-LABEL: f1:
|
2018-01-16 05:32:39 +08:00
|
|
|
; CHECK: # %bb.0:
|
|
|
|
; CHECK-NEXT: pushq %rbp # encoding: [0x55]
|
|
|
|
; CHECK-NEXT: movq %rsp, %rbp # encoding: [0x48,0x89,0xe5]
|
|
|
|
; CHECK-NEXT: andq $-32, %rsp # encoding: [0x48,0x83,0xe4,0xe0]
|
|
|
|
; CHECK-NEXT: movq %rbp, %rsp # encoding: [0x48,0x89,0xec]
|
|
|
|
; CHECK-NEXT: popq %rbp # encoding: [0x5d]
|
|
|
|
; CHECK-NEXT: retq # encoding: [0xc3]
|
2015-07-17 08:57:52 +08:00
|
|
|
%foo = alloca i8, align 32
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2018-01-16 05:32:39 +08:00
|
|
|
define void @f2(i16 %x, i1 *%y) nounwind {
|
2015-07-17 08:57:52 +08:00
|
|
|
; CHECK-LABEL: f2:
|
2018-01-16 05:32:39 +08:00
|
|
|
; CHECK: # %bb.0:
|
|
|
|
; CHECK-NEXT: andl $1, %edi # encoding: [0x83,0xe7,0x01]
|
|
|
|
; CHECK-NEXT: movb %dil, (%rsi) # encoding: [0x40,0x88,0x3e]
|
|
|
|
; CHECK-NEXT: retq # encoding: [0xc3]
|
2016-02-25 15:05:12 +08:00
|
|
|
%c = trunc i16 %x to i1
|
|
|
|
store i1 %c, i1* %y
|
2015-07-17 08:57:52 +08:00
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2018-01-16 05:32:39 +08:00
|
|
|
define void @f3(i32 %x, i1 *%y) nounwind {
|
2015-07-17 08:57:52 +08:00
|
|
|
; CHECK-LABEL: f3:
|
2018-01-16 05:32:39 +08:00
|
|
|
; CHECK: # %bb.0:
|
|
|
|
; CHECK-NEXT: andl $1, %edi # encoding: [0x83,0xe7,0x01]
|
|
|
|
; CHECK-NEXT: movb %dil, (%rsi) # encoding: [0x40,0x88,0x3e]
|
|
|
|
; CHECK-NEXT: retq # encoding: [0xc3]
|
2016-02-25 15:05:12 +08:00
|
|
|
%c = trunc i32 %x to i1
|
|
|
|
store i1 %c, i1* %y
|
|
|
|
ret void
|
2015-07-17 08:57:52 +08:00
|
|
|
}
|
2018-01-16 05:32:39 +08:00
|
|
|
|
2018-01-16 05:57:41 +08:00
|
|
|
; The immediate (0x0ffffff0) can be made into an i8 by making it negative.
|
|
|
|
|
|
|
|
define i32 @lopped32_32to8(i32 %x) {
|
|
|
|
; CHECK-LABEL: lopped32_32to8:
|
|
|
|
; CHECK: # %bb.0:
|
|
|
|
; CHECK-NEXT: movl %edi, %eax # encoding: [0x89,0xf8]
|
2018-09-20 02:59:08 +08:00
|
|
|
; CHECK-NEXT: shrl $4, %eax # encoding: [0xc1,0xe8,0x04]
|
|
|
|
; CHECK-NEXT: andl $-16, %eax # encoding: [0x83,0xe0,0xf0]
|
2018-01-16 05:57:41 +08:00
|
|
|
; CHECK-NEXT: retq # encoding: [0xc3]
|
|
|
|
%shr = lshr i32 %x, 4
|
|
|
|
%and = and i32 %shr, 268435440
|
|
|
|
ret i32 %and
|
|
|
|
}
|
|
|
|
|
|
|
|
; The immediate (0x0ffffff0) can be made into an i8 by making it negative.
|
|
|
|
|
|
|
|
define i64 @lopped64_32to8(i64 %x) {
|
|
|
|
; CHECK-LABEL: lopped64_32to8:
|
|
|
|
; CHECK: # %bb.0:
|
|
|
|
; CHECK-NEXT: movq %rdi, %rax # encoding: [0x48,0x89,0xf8]
|
2018-09-20 02:59:08 +08:00
|
|
|
; CHECK-NEXT: shrq $36, %rax # encoding: [0x48,0xc1,0xe8,0x24]
|
|
|
|
; CHECK-NEXT: andl $-16, %eax # encoding: [0x83,0xe0,0xf0]
|
2018-01-16 05:57:41 +08:00
|
|
|
; CHECK-NEXT: retq # encoding: [0xc3]
|
|
|
|
%shr = lshr i64 %x, 36
|
|
|
|
%and = and i64 %shr, 268435440
|
|
|
|
ret i64 %and
|
|
|
|
}
|
|
|
|
|
|
|
|
; The immediate (0x0ffffffffffffff0) can be made into an i8 by making it negative.
|
|
|
|
|
|
|
|
define i64 @lopped64_64to8(i64 %x) {
|
|
|
|
; CHECK-LABEL: lopped64_64to8:
|
|
|
|
; CHECK: # %bb.0:
|
2018-01-20 00:37:25 +08:00
|
|
|
; CHECK-NEXT: movq %rdi, %rax # encoding: [0x48,0x89,0xf8]
|
2018-09-20 02:59:08 +08:00
|
|
|
; CHECK-NEXT: shrq $4, %rax # encoding: [0x48,0xc1,0xe8,0x04]
|
|
|
|
; CHECK-NEXT: andq $-16, %rax # encoding: [0x48,0x83,0xe0,0xf0]
|
2018-01-16 05:57:41 +08:00
|
|
|
; CHECK-NEXT: retq # encoding: [0xc3]
|
|
|
|
%shr = lshr i64 %x, 4
|
|
|
|
%and = and i64 %shr, 1152921504606846960
|
|
|
|
ret i64 %and
|
|
|
|
}
|
|
|
|
|
|
|
|
; The immediate (0x0ffffffffff0fff0) can be made into an i32 by making it negative.
|
|
|
|
|
|
|
|
define i64 @lopped64_64to32(i64 %x) {
|
|
|
|
; CHECK-LABEL: lopped64_64to32:
|
|
|
|
; CHECK: # %bb.0:
|
2018-01-20 00:37:25 +08:00
|
|
|
; CHECK-NEXT: movq %rdi, %rax # encoding: [0x48,0x89,0xf8]
|
2018-09-20 02:59:08 +08:00
|
|
|
; CHECK-NEXT: shrq $4, %rax # encoding: [0x48,0xc1,0xe8,0x04]
|
|
|
|
; CHECK-NEXT: andq $-983056, %rax # encoding: [0x48,0x25,0xf0,0xff,0xf0,0xff]
|
|
|
|
; CHECK-NEXT: # imm = 0xFFF0FFF0
|
2018-01-16 05:57:41 +08:00
|
|
|
; CHECK-NEXT: retq # encoding: [0xc3]
|
|
|
|
%shr = lshr i64 %x, 4
|
|
|
|
%and = and i64 %shr, 1152921504605863920
|
|
|
|
ret i64 %and
|
|
|
|
}
|
|
|
|
|
|
|
|
; The transform is not limited to shifts - computeKnownBits() knows the top 4 bits
|
|
|
|
; must be cleared, so 0x0fffff80 can become 0x80 sign-extended.
|
|
|
|
|
|
|
|
define i32 @shrinkAndKnownBits(i32 %x) {
|
|
|
|
; CHECK-LABEL: shrinkAndKnownBits:
|
|
|
|
; CHECK: # %bb.0:
|
|
|
|
; CHECK-NEXT: movl %edi, %ecx # encoding: [0x89,0xf9]
|
|
|
|
; CHECK-NEXT: movl $4042322161, %eax # encoding: [0xb8,0xf1,0xf0,0xf0,0xf0]
|
|
|
|
; CHECK-NEXT: # imm = 0xF0F0F0F1
|
|
|
|
; CHECK-NEXT: imulq %rcx, %rax # encoding: [0x48,0x0f,0xaf,0xc1]
|
|
|
|
; CHECK-NEXT: shrq $36, %rax # encoding: [0x48,0xc1,0xe8,0x24]
|
2018-01-20 00:37:25 +08:00
|
|
|
; CHECK-NEXT: andl $-128, %eax # encoding: [0x83,0xe0,0x80]
|
2018-02-01 06:04:26 +08:00
|
|
|
; CHECK-NEXT: # kill: def $eax killed $eax killed $rax
|
2018-01-16 05:57:41 +08:00
|
|
|
; CHECK-NEXT: retq # encoding: [0xc3]
|
|
|
|
%div = udiv i32 %x, 17
|
|
|
|
%and = and i32 %div, 268435328
|
|
|
|
ret i32 %and
|
|
|
|
}
|
|
|
|
|