https://bugs.llvm.org/show_bug.cgi?id=39476
Bug ID: 39476
Summary: Failure to simplify std::abs(a) * std::abs(a) -> a*a
Product: libraries
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: Common Code Generator Code
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected],
[email protected], [email protected]
#include <algorithm>
int bar_s32(int a)
{
return std::abs(a) * std::abs(a);
}
float bar_f32(float a)
{
return std::abs(a) * std::abs(a);
}
https://godbolt.org/z/4vIPwf
clang manages this for fabs but not iabs:
_Z7bar_s32i: # @_Z7bar_s32i
movl %edi, %eax
negl %eax
cmovll %edi, %eax
imull %eax, %eax
retq
_Z7bar_f32f: # @_Z7bar_f32f
mulss %xmm0, %xmm0
retq
gcc:
_Z7bar_s32i:
imull %edi, %edi
movl %edi, %eax
ret
_Z7bar_f32f:
mulss %xmm0, %xmm0
ret
--
You are receiving this mail because:
You are on the CC list for the bug._______________________________________________
llvm-bugs mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs