This is an archive of the discontinued LLVM Phabricator instance.

Add support to vectorize ctlz,cttz and powi intrinsics in LoopVectorizer
ClosedPublic

Authored by karthikthecool on May 28 2014, 5:57 AM.

Details

Summary

Hi Nadav,Arnold,
This is a follow up patch after http://reviews.llvm.org/D3851 .
Patch adds support to vectorize intrinsics powi,cttz,ctlz in Loopvectorizer.
Please if you could review these 2 patches.

Thanks
Karthik Bhat

Diff Detail

Event Timeline

karthikthecool retitled this revision from to Add support to vectorize ctlz,cttz and powi intrinsics in LoopVectorizer.
karthikthecool updated this object.
karthikthecool edited the test plan for this revision. (Show Details)
karthikthecool added a subscriber: Unknown Object (MLST).
aschwaighofer edited edge metadata.May 29 2014, 1:06 PM

With those changes this LGTM.

Did you run performance tests? Did you see any impact on the test-suite?

Thanks

lib/Transforms/Vectorize/LoopVectorize.cpp
3084

This code is nearly identical to the code in the default statement below. I think this could be refactored into common code?

default:
      bool HasScalarOpd = hasVectorInstrinsicScalarOpd(ID, 1);
      for (unsigned Part = 0; Part < UF; ++Part) {
        SmallVector<Value *, 4> Args;
        for (unsigned i = 0, ie = CI->getNumArgOperands(); i != ie; ++i) {
          if (HasScalarOpd && i == 1) {
             // pushback scalar.
             continue;
          }
          VectorParts &Arg = getVectorValue(CI->getArgOperand(i));
          Args.push_back(Arg[Part]);
        }
        Type *Tys[] = {CI->getType()};
        if (VF > 1)
          Tys[0] = VectorType::get(CI->getType()->getScalarType(), VF);

        Function *F = Intrinsic::getDeclaration(M, ID, Tys);
        Entry[Part] = Builder.CreateCall(F, Args);
      }
      break;
    }
3438

is the same (i.e. loop invariant).

karthikthecool accepted this revision.May 29 2014, 9:43 PM
karthikthecool added a reviewer: karthikthecool.

Thanks Arnold for the review. Committed as r209873.
I have not yet run performance test. I will run lnt performance test cases over the weekend and update you with the numbers.
Thanks!

This revision is now accepted and ready to land.May 29 2014, 9:43 PM
karthikthecool closed this revision.Jun 3 2014, 9:53 PM