1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 3
2 ; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+sse2 | FileCheck %s --check-prefixes=X86
3 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx | FileCheck %s --check-prefixes=X64
5 define i32 @sext_known_nonzero(i16 %xx) {
6 ; X86-LABEL: sext_known_nonzero:
8 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
9 ; X86-NEXT: movl $256, %eax # imm = 0x100
10 ; X86-NEXT: shll %cl, %eax
12 ; X86-NEXT: bsfl %eax, %ecx
13 ; X86-NEXT: movl $32, %eax
14 ; X86-NEXT: cmovnel %ecx, %eax
17 ; X64-LABEL: sext_known_nonzero:
19 ; X64-NEXT: movl %edi, %ecx
20 ; X64-NEXT: movl $256, %eax # imm = 0x100
21 ; X64-NEXT: # kill: def $cl killed $cl killed $ecx
22 ; X64-NEXT: shll %cl, %eax
23 ; X64-NEXT: movswq %ax, %rax
24 ; X64-NEXT: movabsq $4294967296, %rcx # imm = 0x100000000
25 ; X64-NEXT: orq %rax, %rcx
26 ; X64-NEXT: rep bsfq %rcx, %rax
27 ; X64-NEXT: # kill: def $eax killed $eax killed $rax
30 %z = sext i16 %x to i32
31 %r = call i32 @llvm.cttz.i32(i32 %z, i1 false)
35 define i32 @sext_known_nonzero_nuw(i16 %xx) {
36 ; X86-LABEL: sext_known_nonzero_nuw:
38 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
39 ; X86-NEXT: movl $256, %eax # imm = 0x100
40 ; X86-NEXT: shll %cl, %eax
42 ; X86-NEXT: rep bsfl %eax, %eax
45 ; X64-LABEL: sext_known_nonzero_nuw:
47 ; X64-NEXT: movl %edi, %ecx
48 ; X64-NEXT: movl $256, %eax # imm = 0x100
49 ; X64-NEXT: # kill: def $cl killed $cl killed $ecx
50 ; X64-NEXT: shll %cl, %eax
52 ; X64-NEXT: rep bsfl %eax, %eax
54 %x = shl nuw i16 256, %xx
55 %z = sext i16 %x to i32
56 %r = call i32 @llvm.cttz.i32(i32 %z, i1 false)
60 define i32 @sext_known_nonzero_nsw(i16 %xx) {
61 ; X86-LABEL: sext_known_nonzero_nsw:
63 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
64 ; X86-NEXT: movl $256, %eax # imm = 0x100
65 ; X86-NEXT: shll %cl, %eax
66 ; X86-NEXT: movzwl %ax, %eax
67 ; X86-NEXT: rep bsfl %eax, %eax
70 ; X64-LABEL: sext_known_nonzero_nsw:
72 ; X64-NEXT: movl %edi, %ecx
73 ; X64-NEXT: movl $256, %eax # imm = 0x100
74 ; X64-NEXT: # kill: def $cl killed $cl killed $ecx
75 ; X64-NEXT: shll %cl, %eax
76 ; X64-NEXT: movzwl %ax, %eax
77 ; X64-NEXT: rep bsfl %eax, %eax
79 %x = shl nsw i16 256, %xx
80 %z = sext i16 %x to i32
81 %r = call i32 @llvm.cttz.i32(i32 %z, i1 false)
85 define i32 @sext_known_nonzero_nuw_nsw(i16 %xx) {
86 ; X86-LABEL: sext_known_nonzero_nuw_nsw:
88 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
89 ; X86-NEXT: movl $256, %eax # imm = 0x100
90 ; X86-NEXT: shll %cl, %eax
91 ; X86-NEXT: movzwl %ax, %eax
92 ; X86-NEXT: rep bsfl %eax, %eax
95 ; X64-LABEL: sext_known_nonzero_nuw_nsw:
97 ; X64-NEXT: movl %edi, %ecx
98 ; X64-NEXT: movl $256, %eax # imm = 0x100
99 ; X64-NEXT: # kill: def $cl killed $cl killed $ecx
100 ; X64-NEXT: shll %cl, %eax
101 ; X64-NEXT: movzwl %ax, %eax
102 ; X64-NEXT: rep bsfl %eax, %eax
104 %x = shl nuw nsw i16 256, %xx
105 %z = sext i16 %x to i32
106 %r = call i32 @llvm.cttz.i32(i32 %z, i1 false)