This is an archive of the discontinued LLVM Phabricator instance.

Loop Vectorizer - skiping "bitcast" allows to vectorize more loops
ClosedPublic

Authored by delena on Oct 20 2015, 3:52 AM.

Details

Summary

Vectorization of memory instruction (Load/Store) is possible when the pointer is coming from GEP. The GEP analysis allows to estimate the profit.
In some cases we have a "bitcast" between GEP and memory instruction.
I added code that skips the "bitcast".

I replaced vectorization-remarks-profitable.ll test. As a result of the optimization, the remarks about non-beneficial vectorization disappeared and loop became vectorizable. I put another loops, that generate the same remarks as the previous.

Diff Detail

Repository
rL LLVM

Event Timeline

delena updated this revision to Diff 37840.Oct 20 2015, 3:52 AM
delena retitled this revision from to Loop Vectorizer - skiping "bitcast" allows to vectorize more loops.
delena updated this object.
delena set the repository for this revision to rL LLVM.
delena added a subscriber: llvm-commits.
jmolloy accepted this revision.Oct 26 2015, 5:41 AM
jmolloy added a reviewer: jmolloy.
jmolloy added a subscriber: jmolloy.

Hi Elena,

I think this looks reasonable.

Cheers,

James

This revision is now accepted and ready to land.Oct 26 2015, 5:41 AM
delena closed this revision.Oct 26 2015, 6:07 AM

Thanks a lot, James!

mzolotukhin edited edge metadata.Oct 26 2015, 10:58 AM

Hi Elena,

The change looks reasonable, one question from me inline.

Thanks,
Michael

../test/Transforms/LoopVectorize/gep_with_bitcast.ll
28–29

Could it be a problem if we cast from, say, double** to i8*? Should we check the type we're pointing to when we do this?

Seems this caused miscompilation for lib/ExecutionEngine/Interpreter/Execution.cpp
Investigating.

../lib/Transforms/Vectorize/LoopVectorize.cpp
262
if (auto GEP = dyn_cast<GetElementPtrInst>(Ptr)) return GEP;
266
if (auto BC = dyn_cast<BCI>(Ptr)) if (auto GEP = dyn_cast<GEP>(BC->getOperand(0))) return GEP;
delena added a subscriber: delena.Oct 27 2015, 11:15 AM

I will revert the commit tomorrow morning. Today is too late for me, I'm connected from home.

  • Elena

Elena, I have reverted this in r251436.