This is an archive of the discontinued LLVM Phabricator instance.

[LoopVectorizer] use TTI.getOperandInfo()
ClosedPublic

Authored by jonpa on Oct 4 2018, 5:22 AM.

Details

Summary

Call getOperandInfo() instead of using (near) duplicated code in LoopVectorizationCostModel::getInstructionCost().

This gets the OperandValueKind and OperandValueProperties values for a Value passed as operand to an arithmetic instruction.

getOperandInfo() used to be a static method in TargetTransformInfo.cpp, but is now instead a public member. The method definition has been moved in the .cpp file to above getArithmeticInstrCost(), from the area of the static functions.

Diff Detail

Event Timeline

jonpa created this revision.Oct 4 2018, 5:22 AM
fhahn added inline comments.Oct 4 2018, 7:30 AM
lib/Analysis/TargetTransformInfo.cpp
390

Can TargetTransformInfo:: be dropped now that it is defined as a member function? That might make it slightly easier to read.

jonpa updated this revision to Diff 168297.Oct 4 2018, 8:43 AM

TargetTransformInfo:: name parts removed in member function (did not compile if I also removed it on the return type).

fhahn accepted this revision.Oct 4 2018, 8:55 AM

LGTM

lib/Transforms/Vectorize/LoopVectorize.cpp
5671–5672

There's no need to initialize Op2VK here, it could just take the result of getOperandInfo directly.

This revision is now accepted and ready to land.Oct 4 2018, 8:55 AM
jonpa updated this revision to Diff 168468.Oct 5 2018, 7:14 AM

OK, I removed the initializer per your suggestion. I also removed the declarations of Op1VK and Op1VP, since this made the code more compact and also a bit more readable in the sense of which operand is actually being analyzed.

Does this look good to you?

jonpa requested review of this revision.Oct 5 2018, 7:15 AM
fhahn accepted this revision.Oct 5 2018, 7:17 AM

Great, that was exactly what I has hoping for! LGTM

This revision is now accepted and ready to land.Oct 5 2018, 7:17 AM
jonpa closed this revision.Oct 5 2018, 7:36 AM

Thanks for review!

r343852.