[PATCH] D43256: [MBP] Move a latch block with conditional exit and multi predecessors to top of loop

Guozhi Wei via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 22 10:51:22 PDT 2019


Carrot added a comment.

Evgeniy, could you try to build your code with FDO? The layout code is based on profile information, if that is not available, the static estimated profile information is used. Since the loaded values are not NaN, there should be no branch from loop header to latch, but the estimated profile gives it a non trivial value, so the latch is moved before header, and one taken branch is reduced in the NaN path. I think the static profile estimation can be enhanced to treat a floating point number as not a NaN, or as a NaN only with a very small possibility.

I tried to reproduce your result with

clang++ -O2 -c d43256.cc -save-temps

#include<algorithm>

#define N 320000

float a[N];
float b[N];
float c[N];

using namespace std;

void foo(int M) {

  for (int i = 0; i < M; i++) {
   c[i] = min(a[i], b[i]);
  }

}

But I got totally different code sequence. Could you help to give more complete reproduce steps?
Thanks a lot!


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D43256/new/

https://reviews.llvm.org/D43256





More information about the llvm-commits mailing list