llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

[GVN] Incorrect non-local load elimination

Open dantrushin opened this issue 2 years ago • 0 comments

Attached test case demonstrates incorrect 'non-local' load elimination. Basically, test does following:

for (i = ... ) {
  array[2] += i;
  array[3] += i;
  array[3] *= -1802;
  array[2] += i;
  array[3] += i;
}

but with fancy CFG (and this fancy CFG is required to reproduce issue). LLVM vectorizes increments of array[2:3] and then GVN removes second vector load not noticing that array[3] element was updated between two loads. (See BB latch where load %val.array.2_3.3 is eliminated) gvn_nonlocal_dep.txt Attached test renamed to .txt from .ll

Also Compiler explorer link

dantrushin avatar Jun 27 '23 17:06 dantrushin