Issue 169433
Summary [flang] missed optimization of product intrinsic
Labels flang
Assignees
Reporter foxtran
    For the following code:
```
subroutine sum_and_prod(v, n, s, p)
  implicit none (type, external)
  integer, intent(in) :: n
  real, intent(in) :: v(n)
  real, intent(out) :: s, p
  s = sum(v)
  p = product(v)
end subroutine sum_and_prod
```
flang produces native ASM code for summation, while for product there is a call to runtime library.

Even if length of vector is known:
```
subroutine sum_and_prod_vec3(v, s, p)
  implicit none (type, external)
  real, intent(in) :: v(3)
  real, intent(out) :: s, p
 s = sum(v)
  p = product(v)
end subroutine sum_and_prod_vec3
```
ASM still have call of runtime library.

It would be nice to avoid any calls especially for short arrays.

ASM output:
https://godbolt.org/z/d3Edr9GG4
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to