<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - Failure to simplify select(-1,+1,cond)*b -> select(-b,b,cond)"
href="https://bugs.llvm.org/show_bug.cgi?id=39479">39479</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Failure to simplify select(-1,+1,cond)*b -> select(-b,b,cond)
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Common Code Generator Code
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>llvm-dev@redking.me.uk
</td>
</tr>
<tr>
<th>CC</th>
<td>filcab@gmail.com, llvm-bugs@lists.llvm.org, spatel+llvm@rotateright.com, tilkax@gmail.com
</td>
</tr></table>
<p>
<div>
<pre>#include <math.h>
int sel_mul_s32(bool a, int b)
{
return (a ? -1 : 1) * b;
}
float sel_mul_f32(bool a, float b)
{
return (a ? -1 : 1) * b;
}
<a href="https://godbolt.org/z/nGT8f_">https://godbolt.org/z/nGT8f_</a>
clang:
_Z11sel_mul_s32bi: # @_Z11sel_mul_s32bi
xorb $1, %dil
movzbl %dil, %eax
leal -1(%rax,%rax), %eax
imull %esi, %eax
retq
_Z11sel_mul_f32bf: # @_Z11sel_mul_f32bf
testl %edi, %edi
jne .LBB1_1
vmovss .LCPI1_1(%rip), %xmm1 # xmm1 = mem[0],zero,zero,zero
vmulss %xmm0, %xmm1, %xmm0
retq
.LBB1_1:
vmovss .LCPI1_0(%rip), %xmm1 # xmm1 = mem[0],zero,zero,zero
vmulss %xmm0, %xmm1, %xmm0
retq
gcc:
_Z11sel_mul_s32bi:
testb %dil, %dil
movl %esi, %eax
je .L6
negl %eax
.L6:
ret
_Z11sel_mul_f32bf:
testb %dil, %dil
je .L13
vxorps .LC0(%rip), %xmm0, %xmm0
.L13:
ret</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>