[llvm-bugs] [Bug 39476] New: Failure to simplify std::abs(a) * std::abs(a) -> a*a

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Oct 29 06:48:47 PDT 2018


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: unassignedbugs at nondot.org
          Reporter: llvm-dev at redking.me.uk
                CC: filcab at gmail.com, llvm-bugs at lists.llvm.org,
                    spatel+llvm at rotateright.com, tilkax at gmail.com

#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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20181029/bb100ae2/attachment.html>


More information about the llvm-bugs mailing list