This is an archive of the discontinued LLVM Phabricator instance.

[LoopVectorizer] Fixed a bug in gather/scatter intrinsics.
ClosedPublic

Authored by delena on Jul 6 2016, 12:48 AM.

Details

Summary

The bug was in building vector GEP before gather scatter.
Index of GEP may remain scalar if it is nit defined inside the loop. (isLoopInvariant() condition is not enough).

The patch fixes https://llvm.org/bugs/show_bug.cgi?id=27997.

You see a lot of insert/extract instructions inside the test. I'll optimize this in the next patch.

Diff Detail

Repository
rL LLVM

Event Timeline

delena updated this revision to Diff 62828.Jul 6 2016, 12:48 AM
delena retitled this revision from to [LoopVectorizer] Fixed a bug in gather/scatter intrinsics..
delena updated this object.
delena added a reviewer: Ayal.
delena set the repository for this revision to rL LLVM.
delena added subscribers: llvm-commits, sanjoy.
delena updated this revision to Diff 62855.Jul 6 2016, 6:28 AM

Changed form of the code, NFC.

Ayal edited edge metadata.Jul 6 2016, 6:59 AM

This looks good to me, with minor nits.

../lib/Transforms/Vectorize/LoopVectorize.cpp
2695–2696

Better emphasize that:
we want to get a vector value for base and each index that's defined inside the loop, even if it is loop-invariant but wasn't hoisted out. Otherwise we want to keep them scalar.

2697–2699

Can simply keep the original OpsV.push_back(VectorParts(UF, Op)), right?

2715

Just noting that this is an independent, obvious, fix.

../test/Transforms/LoopVectorize/X86/scatter_crash.ll
13

Indicate more clearly what this test is designed to check for?

This revision was automatically updated to reflect the committed changes.