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

[Loop Vectorizer] Loop not vectorized when accessing the same pointer with different offsets.

Open komalon1 opened this issue 2 years ago • 5 comments

See reproducer in https://godbolt.org/z/v7fqorb1h. a2 = a1 + 256; a2 has an interleaved store access, and a1 has a simple linear access. There are no actual dependencies between them when VF is 4, and it looks safe for the loop to be vectorized. BTW, changing a2[2*i] to a2[i] makes vectorization safe.

komalon1 avatar Apr 02 '24 11:04 komalon1

gcc support this: https://godbolt.org/z/zGjhha5qx

vfdff avatar Apr 03 '24 07:04 vfdff

Looks like there are a couple of improvements needed, looking now

fhahn avatar Apr 04 '24 11:04 fhahn

@fhahn Is this issue really closed? I see the reproducer still doesn't vectorize.

komalon1 avatar Feb 11 '25 12:02 komalon1

@komalon1 could you check again? The reproducer from the Godbolt should now vectorize.

fhahn avatar Jul 11 '25 17:07 fhahn

@komalon1 could you check again? The reproducer from the Godbolt should now vectorize.

looks good now, thanks!

komalon1 avatar Jul 13 '25 08:07 komalon1