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: testl %eax, %eax
13 ; X86-NEXT: je .LBB0_1
14 ; X86-NEXT: # %bb.2: # %cond.false
15 ; X86-NEXT: rep bsfl %eax, %eax
18 ; X86-NEXT: movl $32, %eax
21 ; X64-LABEL: sext_known_nonzero:
23 ; X64-NEXT: movl %edi, %ecx
24 ; X64-NEXT: movl $256, %eax # imm = 0x100
25 ; X64-NEXT: # kill: def $cl killed $cl killed $ecx
26 ; X64-NEXT: shll %cl, %eax
28 ; X64-NEXT: testl %eax, %eax
29 ; X64-NEXT: je .LBB0_1
30 ; X64-NEXT: # %bb.2: # %cond.false
31 ; X64-NEXT: rep bsfl %eax, %eax
34 ; X64-NEXT: movl $32, %eax
37 %z = sext i16 %x to i32
38 %r = call i32 @llvm.cttz.i32(i32 %z, i1 false)
42 define i32 @sext_known_nonzero_nuw(i16 %xx) {
43 ; X86-LABEL: sext_known_nonzero_nuw:
45 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
46 ; X86-NEXT: movl $256, %eax # imm = 0x100
47 ; X86-NEXT: shll %cl, %eax
49 ; X86-NEXT: rep bsfl %eax, %eax
52 ; X64-LABEL: sext_known_nonzero_nuw:
54 ; X64-NEXT: movl %edi, %ecx
55 ; X64-NEXT: movl $256, %eax # imm = 0x100
56 ; X64-NEXT: # kill: def $cl killed $cl killed $ecx
57 ; X64-NEXT: shll %cl, %eax
59 ; X64-NEXT: rep bsfl %eax, %eax
61 %x = shl nuw i16 256, %xx
62 %z = sext i16 %x to i32
63 %r = call i32 @llvm.cttz.i32(i32 %z, i1 false)
67 define i32 @sext_known_nonzero_nsw(i16 %xx) {
68 ; X86-LABEL: sext_known_nonzero_nsw:
70 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
71 ; X86-NEXT: movl $256, %eax # imm = 0x100
72 ; X86-NEXT: shll %cl, %eax
73 ; X86-NEXT: movzwl %ax, %eax
74 ; X86-NEXT: rep bsfl %eax, %eax
77 ; X64-LABEL: sext_known_nonzero_nsw:
79 ; X64-NEXT: movl %edi, %ecx
80 ; X64-NEXT: movl $256, %eax # imm = 0x100
81 ; X64-NEXT: # kill: def $cl killed $cl killed $ecx
82 ; X64-NEXT: shll %cl, %eax
83 ; X64-NEXT: movzwl %ax, %eax
84 ; X64-NEXT: rep bsfl %eax, %eax
86 %x = shl nsw i16 256, %xx
87 %z = sext i16 %x to i32
88 %r = call i32 @llvm.cttz.i32(i32 %z, i1 false)
92 define i32 @sext_known_nonzero_nuw_nsw(i16 %xx) {
93 ; X86-LABEL: sext_known_nonzero_nuw_nsw:
95 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
96 ; X86-NEXT: movl $256, %eax # imm = 0x100
97 ; X86-NEXT: shll %cl, %eax
98 ; X86-NEXT: movzwl %ax, %eax
99 ; X86-NEXT: rep bsfl %eax, %eax
102 ; X64-LABEL: sext_known_nonzero_nuw_nsw:
104 ; X64-NEXT: movl %edi, %ecx
105 ; X64-NEXT: movl $256, %eax # imm = 0x100
106 ; X64-NEXT: # kill: def $cl killed $cl killed $ecx
107 ; X64-NEXT: shll %cl, %eax
108 ; X64-NEXT: movzwl %ax, %eax
109 ; X64-NEXT: rep bsfl %eax, %eax
111 %x = shl nuw nsw i16 256, %xx
112 %z = sext i16 %x to i32
113 %r = call i32 @llvm.cttz.i32(i32 %z, i1 false)