[llvm-bugs] [Bug 47613] New: InstCombine leaves extra call to sqrtf from pow transform

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Sep 22 10:51:42 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=47613

            Bug ID: 47613
           Summary: InstCombine leaves extra call to sqrtf from pow
                    transform
           Product: libraries
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Transformation Utilities
          Assignee: unassignedbugs at nondot.org
          Reporter: hstong at ca.ibm.com
                CC: llvm-bugs at lists.llvm.org, spatel+llvm at rotateright.com

As noted in the review of D88066, there is an extra `sqrtf` call formed from
the call to `pow` in `shrink_pow_libcall_half` (below, extracted from
`llvm/test/Transforms/InstCombine/pow-4.ll`).

### SOURCE (<stdin>):
declare double @pow(double, double)

define float @shrink_pow_libcall_half(float %x) {
  %dx = fpext float %x to double
  %call = call fast double @pow(double %dx, double 0.5)
  %fr = fptrunc double %call to float
  ret float %fr
}


### LLVM INVOCATION:
opt -instcombine -S


### ACTUAL OUTPUT:
; ModuleID = '<stdin>'
source_filename = "<stdin>"

declare double @pow(double, double)

define float @shrink_pow_libcall_half(float %x) {
  %sqrtf = call fast float @sqrtf(float %x)
  %sqrtf1 = call fast float @sqrtf(float %x)
  ret float %sqrtf1
}

declare float @powf(float, float)

declare double @sqrt(double)

declare float @sqrtf(float)


### EXPECTED OUTPUT:
(only one call to `sqrtf`)


### LLVM VERSION INFO (opt --version):
LLVM (http://llvm.org/):
  LLVM version 12.0.0git
  Optimized build.
  Default target: x86_64-unknown-linux-gnu
  Host CPU: sandybridge


### LLVM VERSION INFO:
https://github.com/llvm/llvm-project.git
a8b8a9374a3c555ac8528fc37b92935554083b9f

-- 
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/20200922/6872b057/attachment.html>


More information about the llvm-bugs mailing list