1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=i686-unknown-linux-gnu < %s | FileCheck %s --check-prefixes=X86
3 ; RUN: llc -mtriple=x86_64-unknown-linux-gnu < %s | FileCheck %s --check-prefixes=X64
5 declare i64 @llvm.abs.i64(i64, i1)
6 declare i32 @llvm.abs.i32(i32, i1)
7 declare i16 @llvm.abs.i16(i16, i1)
8 declare i8 @llvm.abs.i8(i8, i1)
10 define i64 @eq_or_with_dom_abs(i64 %x) nounwind {
11 ; X86-LABEL: eq_or_with_dom_abs:
13 ; X86-NEXT: pushl %ebx
14 ; X86-NEXT: pushl %edi
15 ; X86-NEXT: pushl %esi
16 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
17 ; X86-NEXT: movl %edx, %eax
18 ; X86-NEXT: sarl $31, %eax
19 ; X86-NEXT: xorl %eax, %edx
20 ; X86-NEXT: movl {{[0-9]+}}(%esp), %esi
21 ; X86-NEXT: xorl %eax, %esi
22 ; X86-NEXT: subl %eax, %esi
23 ; X86-NEXT: sbbl %eax, %edx
24 ; X86-NEXT: movl %esi, %eax
25 ; X86-NEXT: xorl $12312, %eax # imm = 0x3018
26 ; X86-NEXT: xorl $64, %esi
27 ; X86-NEXT: xorl %ecx, %ecx
28 ; X86-NEXT: orl %edx, %esi
30 ; X86-NEXT: xorl %esi, %esi
31 ; X86-NEXT: movl $2344, %edi # imm = 0x928
32 ; X86-NEXT: cmpl %eax, %edi
33 ; X86-NEXT: sbbl %edx, %esi
34 ; X86-NEXT: jb .LBB0_2
36 ; X86-NEXT: movb %bl, %cl
37 ; X86-NEXT: xorl %edx, %edx
38 ; X86-NEXT: movl %ecx, %eax
45 ; X64-LABEL: eq_or_with_dom_abs:
47 ; X64-NEXT: movq %rdi, %rcx
49 ; X64-NEXT: cmovsq %rdi, %rcx
50 ; X64-NEXT: movq %rcx, %rdx
51 ; X64-NEXT: xorq $12312, %rdx # imm = 0x3018
52 ; X64-NEXT: xorl %eax, %eax
53 ; X64-NEXT: cmpq $64, %rcx
55 ; X64-NEXT: cmpq $2345, %rdx # imm = 0x929
56 ; X64-NEXT: cmovaeq %rdx, %rax
58 %absx = call i64 @llvm.abs.i64(i64 %x, i1 true)
59 %foo = xor i64 %absx, 12312
60 %bar = icmp ugt i64 %foo, 2344
61 %cmp0 = icmp eq i64 %x, 64
62 %cmp1 = icmp eq i64 %x, -64
63 %cmp = or i1 %cmp0, %cmp1
64 %cmp64 = zext i1 %cmp to i64
65 %r = select i1 %bar, i64 %foo, i64 %cmp64
69 define i32 @eq_or_with_dom_abs_non_po2(i32 %x) nounwind {
70 ; X86-LABEL: eq_or_with_dom_abs_non_po2:
72 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
73 ; X86-NEXT: movl %edx, %eax
74 ; X86-NEXT: sarl $31, %eax
75 ; X86-NEXT: xorl %eax, %edx
76 ; X86-NEXT: subl %eax, %edx
77 ; X86-NEXT: movl %edx, %eax
78 ; X86-NEXT: xorl $12312, %eax # imm = 0x3018
79 ; X86-NEXT: xorl %ecx, %ecx
80 ; X86-NEXT: cmpl $123, %edx
82 ; X86-NEXT: cmpl $2345, %eax # imm = 0x929
83 ; X86-NEXT: jae .LBB1_2
85 ; X86-NEXT: movb %dl, %cl
86 ; X86-NEXT: movl %ecx, %eax
90 ; X64-LABEL: eq_or_with_dom_abs_non_po2:
92 ; X64-NEXT: movl %edi, %ecx
94 ; X64-NEXT: cmovsl %edi, %ecx
95 ; X64-NEXT: movl %ecx, %edx
96 ; X64-NEXT: xorl $12312, %edx # imm = 0x3018
97 ; X64-NEXT: xorl %eax, %eax
98 ; X64-NEXT: cmpl $123, %ecx
100 ; X64-NEXT: cmpl $2345, %edx # imm = 0x929
101 ; X64-NEXT: cmovael %edx, %eax
103 %absx = call i32 @llvm.abs.i32(i32 %x, i1 true)
104 %foo = xor i32 %absx, 12312
105 %bar = icmp ugt i32 %foo, 2344
106 %cmp0 = icmp eq i32 %x, 123
107 %cmp1 = icmp eq i32 %x, -123
108 %cmp = or i1 %cmp0, %cmp1
109 %cmp64 = zext i1 %cmp to i32
110 %r = select i1 %bar, i32 %foo, i32 %cmp64
114 define i8 @ne_and_with_dom_abs_non_pow2(i8 %x) nounwind {
115 ; X86-LABEL: ne_and_with_dom_abs_non_pow2:
117 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
118 ; X86-NEXT: movl %ecx, %eax
119 ; X86-NEXT: sarb $7, %al
120 ; X86-NEXT: xorb %al, %cl
121 ; X86-NEXT: subb %al, %cl
122 ; X86-NEXT: movl %ecx, %eax
123 ; X86-NEXT: xorb $12, %al
124 ; X86-NEXT: cmpb $121, %cl
125 ; X86-NEXT: setne %cl
126 ; X86-NEXT: cmpb $24, %al
127 ; X86-NEXT: jae .LBB2_2
129 ; X86-NEXT: movl %ecx, %eax
133 ; X64-LABEL: ne_and_with_dom_abs_non_pow2:
135 ; X64-NEXT: movl %edi, %eax
136 ; X64-NEXT: sarb $7, %al
137 ; X64-NEXT: xorb %al, %dil
138 ; X64-NEXT: subb %al, %dil
139 ; X64-NEXT: movl %edi, %ecx
140 ; X64-NEXT: xorb $12, %cl
141 ; X64-NEXT: xorl %eax, %eax
142 ; X64-NEXT: cmpb $121, %dil
143 ; X64-NEXT: setne %al
144 ; X64-NEXT: cmpb $24, %cl
145 ; X64-NEXT: movzbl %cl, %ecx
146 ; X64-NEXT: cmovael %ecx, %eax
147 ; X64-NEXT: # kill: def $al killed $al killed $eax
149 %absx = call i8 @llvm.abs.i8(i8 %x, i1 true)
150 %foo = xor i8 %absx, 12
151 %bar = icmp ugt i8 %foo, 23
152 %cmp0 = icmp ne i8 %x, 121
153 %cmp1 = icmp ne i8 %x, -121
154 %cmp = and i1 %cmp0, %cmp1
155 %cmp64 = zext i1 %cmp to i8
156 %r = select i1 %bar, i8 %foo, i8 %cmp64
160 define i16 @ne_and_with_dom_abs(i16 %x) nounwind {
161 ; X86-LABEL: ne_and_with_dom_abs:
163 ; X86-NEXT: pushl %esi
164 ; X86-NEXT: movzwl {{[0-9]+}}(%esp), %ecx
165 ; X86-NEXT: movswl %cx, %eax
166 ; X86-NEXT: sarl $15, %eax
167 ; X86-NEXT: xorl %eax, %ecx
168 ; X86-NEXT: subl %eax, %ecx
169 ; X86-NEXT: movl %ecx, %eax
170 ; X86-NEXT: xorl $12312, %eax # imm = 0x3018
171 ; X86-NEXT: movzwl %ax, %esi
172 ; X86-NEXT: xorl %edx, %edx
173 ; X86-NEXT: cmpw $64, %cx
174 ; X86-NEXT: setne %cl
175 ; X86-NEXT: cmpl $2345, %esi # imm = 0x929
176 ; X86-NEXT: jae .LBB3_2
178 ; X86-NEXT: movb %cl, %dl
179 ; X86-NEXT: movl %edx, %eax
181 ; X86-NEXT: # kill: def $ax killed $ax killed $eax
182 ; X86-NEXT: popl %esi
185 ; X64-LABEL: ne_and_with_dom_abs:
187 ; X64-NEXT: movl %edi, %ecx
189 ; X64-NEXT: cmovsw %di, %cx
190 ; X64-NEXT: movl %ecx, %edx
191 ; X64-NEXT: xorl $12312, %edx # imm = 0x3018
192 ; X64-NEXT: movzwl %dx, %esi
193 ; X64-NEXT: xorl %eax, %eax
194 ; X64-NEXT: cmpw $64, %cx
195 ; X64-NEXT: setne %al
196 ; X64-NEXT: cmpl $2345, %esi # imm = 0x929
197 ; X64-NEXT: cmovael %edx, %eax
198 ; X64-NEXT: # kill: def $ax killed $ax killed $eax
200 %absx = call i16 @llvm.abs.i16(i16 %x, i1 true)
201 %foo = xor i16 %absx, 12312
202 %bar = icmp ugt i16 %foo, 2344
203 %cmp0 = icmp ne i16 %x, 64
204 %cmp1 = icmp ne i16 %x, -64
205 %cmp = and i1 %cmp0, %cmp1
206 %cmp64 = zext i1 %cmp to i16
207 %r = select i1 %bar, i16 %foo, i16 %cmp64