We use getExtractWithExtendCost to calculate the cost of extractelement and s|zext together when computing the extract cost after vectorization, but we calculate the cost of extractelement and s|zext separately when computing the scalar cost which is larger than it should be.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
test/Transforms/SLPVectorizer/AArch64/ext-trunc.ll | ||
---|---|---|
2 | Could you regenerate test checks without your patch and without -instcombine first and commit as NFC? And after that generate these checks with your patch |
lib/Transforms/Vectorize/SLPVectorizer.cpp | ||
---|---|---|
2199 | I think you need to check that Ext user is GEP and Ext is used as GEP index. |
lib/Transforms/Vectorize/SLPVectorizer.cpp | ||
---|---|---|
2201 | I think you can use just GetElementPtr::classof here as a predicate. Also, it would be good to have negative test(s) for the situation where this should not work. |
lib/Transforms/Vectorize/SLPVectorizer.cpp | ||
---|---|---|
2201 | No, I meant that instead of lambda you can just use GetElementPtrInst::classof llvm::all_of(Ext->users(), GetElementPtrInst::classof) |
lib/Transforms/Vectorize/SLPVectorizer.cpp | ||
---|---|---|
2201 | I tried, but I got this error when compiling llvm/ADT/STLExtras.h:846:6: note: candidate template ignored: couldn't infer template argument 'UnaryPredicate' |
lib/Transforms/Vectorize/SLPVectorizer.cpp | ||
---|---|---|
2201 | Ok then, revert back to isa |
I think you need to check that Ext user is GEP and Ext is used as GEP index.