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

--- Comment #9 from H.J. Lu <hjl.tools at gmail dot com> ---
(In reply to Jeffrey A. Law from comment #8)
> That's an indication you've likely done something wrong with your local
> properties HJ.  LCM inherently also does LICM since LICM is just a special
> case of PRE.

The LCM algorithm isn't appropriate here since it may place a vxorps
inside the loop.  Simple testcase show this:

$ cat badcase.c

extern float f;
extern double d;
extern int i;

void
foo (int n, int k)
{
  for (int j = 0; j != n; j++)
    if (j < k)
      d = f;
}

It generates

    ...
    loop:
      if(j < k)
        vxorps  %xmm0, %xmm0, %xmm0
        vcvtss2sd  %xmm1, %xmm0, %xmm0
      ...
    loopend
    ...

This is because LCM only works when there is a certain benifit.  But for
conditional branch, LCM wouldn't move

   vxorps  %xmm0, %xmm0, %xmm0

out of loop. It's suboptimal.

Reply via email to