https://bugs.llvm.org/show_bug.cgi?id=39479
Bug ID: 39479
Summary: Failure to simplify select(-1,+1,cond)*b ->
select(-b,b,cond)
Product: libraries
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: Common Code Generator Code
Assignee: unassignedb...@nondot.org
Reporter: llvm-...@redking.me.uk
CC: fil...@gmail.com, llvm-bugs@lists.llvm.org,
spatel+l...@rotateright.com, til...@gmail.com
#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;
}
https://godbolt.org/z/nGT8f_
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
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs