This is an archive of the discontinued LLVM Phabricator instance.

SLPVectorizer: Fix assert with different sized address spaces
ClosedPublic

Authored by arsenm on Aug 29 2018, 8:13 AM.

Details

Diff Detail

Event Timeline

arsenm created this revision.Aug 29 2018, 8:13 AM
ABataev added inline comments.Aug 29 2018, 9:27 AM
lib/Transforms/Vectorize/SLPVectorizer.cpp
6402

I don't think this is correct. Instead, you should try to collect GEPs with the different address spaces into different nodes

arsenm added inline comments.Aug 29 2018, 11:39 PM
lib/Transforms/Vectorize/SLPVectorizer.cpp
6402

That's what I thought at first, but his isn't vectorizing the GEP itself as far as I can see. It only cares about the index operation, which could be the same size between different address spaces

ABataev added inline comments.Aug 30 2018, 7:55 AM
lib/Transforms/Vectorize/SLPVectorizer.cpp
6402

Yes, I see now. But I still think this not quite correct, just like the original code. As I understand, it tries to vectorize indices with the same base. So, when we gather GEPs, we just don't need to use GetUnderlyingObject(GEP->getPointerOperand(), *DL) as the key, just GEP->getPointerOperand(). I think, we should not dig deep into the base of the GEP.

arsenm added inline comments.Aug 30 2018, 8:25 AM
lib/Transforms/Vectorize/SLPVectorizer.cpp
6402

This isn't considering the bases at all, which makes sense based on this comment:

// Vectorize the index computations of getelementptr instructions. This
// is primarily intended to catch gather-like idioms ending at
// non-consecutive loads.
ABataev added inline comments.Aug 30 2018, 8:31 AM
lib/Transforms/Vectorize/SLPVectorizer.cpp
6402

No, it considers the bases when gathers the GEPs in bundles. These bundles are grouped using GetUnderlyingObject(GEP->getPointerOperand(), *DL) as the key, but instead it should use just GEP->getPointerOperand(). This may effect in best vectorization result, may reduce the compilation time + fix your problem with the compiler crash as all GEPs in bundles will have the same base + index. It means that the types of the SCEVs also will be the same.

arsenm updated this revision to Diff 163465.Aug 31 2018, 12:30 AM

Remove GetUnderlyingObject, improve tests

ABataev added inline comments.Aug 31 2018, 6:24 AM
test/Transforms/SLPVectorizer/AMDGPU/address-space-ptr-sze-gep-index-assert.ll
2

Use utils/update_test_checks.py to generate correct checks for the test

arsenm updated this revision to Diff 163520.Aug 31 2018, 6:35 AM
arsenm marked an inline comment as done.

Use update_test_checks

lebedev.ri added inline comments.
test/Transforms/SLPVectorizer/AMDGPU/address-space-ptr-sze-gep-index-assert.ll
10–15

You need to manually cleanup the old manually-generated check-lines.

arsenm updated this revision to Diff 163522.Aug 31 2018, 6:47 AM

Fix old checks

This revision is now accepted and ready to land.Aug 31 2018, 6:50 AM
arsenm closed this revision.Aug 31 2018, 7:50 AM

r341215