This is an archive of the discontinued LLVM Phabricator instance.

[CostModel] Improve detection of uniform operands
AbandonedPublic

Authored by RKSimon on Jan 8 2017, 11:39 AM.

Details

Summary

Currently we only match uniform operands against a broadcasted scalar, this patch adds support for matching a broadcasted vector value as well.

We still expect the operand to have come from an argument or global value.

Diff Detail

Repository
rL LLVM

Event Timeline

RKSimon updated this revision to Diff 83569.Jan 8 2017, 11:39 AM
RKSimon retitled this revision from to [CostModel] Improve detection of uniform operands.
RKSimon updated this object.
RKSimon added reviewers: mkuper, spatel, andreadb.
RKSimon set the repository for this revision to rL LLVM.
RKSimon added a subscriber: llvm-commits.
mkuper added inline comments.Jan 9 2017, 6:07 PM
lib/Analysis/CostModel.cpp
163

Is this code actually used anywhere, except for the cost-model printer pass?

It looks like the only (in-tree) caller of getOperandInfo() is CostModelAnalysis::getInstructionCost(), but actual cost model consumers don't use getInstructionCost(). Rather, they call getArithmeticInstrCost() directly, and provide their own opinion on the operands' uniformity.

If that's really the case, I'm not entirely sure there's a point in trying to make this more precise.

test/Analysis/CostModel/X86/vshift-ashr-cost.ll
189

This is really curious. How do we end up with a higher cost for a uniform operand than for a nun-uniform one?

RKSimon added inline comments.Jan 10 2017, 8:07 AM
lib/Analysis/CostModel.cpp
163

OK - so do you think we should have a standard helper to determine the ValueKind in all the vectorizers?

test/Analysis/CostModel/X86/vshift-ashr-cost.ll
189

Because trying to straighten out the cost model to match all the special cases in lowering is making my hair grey......

mkuper added inline comments.Jan 10 2017, 11:45 AM
lib/Analysis/CostModel.cpp
163

Unfortunately, I don't think this will work - the analysis is different in each case.
I'm just trying to understand the rationale of this patch.

test/Analysis/CostModel/X86/vshift-ashr-cost.ll
189

:-(
Thanks for all the work you're doing in that space!

RKSimon abandoned this revision.Jan 15 2017, 10:52 AM

Abandoning this - I'm going to update the uniform shift tests to use the broadcast( insert_elt undef, scl, 0 ) pattern instead which should work for the cost model and leave the vectorizer to compute the value kind in their own ways,