https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86350

--- Comment #1 from kargl at gcc dot gnu.org ---
Whoops forgot the code.  This code produces

subroutine foo(x,y)
   real x(10), y(10)
   interface
      impure elemental function bar(x)
         real, intent(inout) :: x
      end function bar
   end interface
   y = 0 * bar(x)
end subroutine foo


.L2:
        movq    %rbp, %rdi
        addq    $4, %rbx
        addq    $4, %rbp
        call    bar_
        pxor    %xmm1, %xmm1
        mulss   %xmm1, %xmm0
        movss   %xmm0, -4(%rbx)
        cmpq    %r13, %rbx
        jne     .L2

whereas the expression 'y = 0 * bar(x)' can be replaced by 'y = 0'.

As similar optimization can be implemented for y = 0 / (some_expression).

Reply via email to