This is an archive of the discontinued LLVM Phabricator instance.

[CostModel] Use operands argument in getInstructionCost in more places
ClosedPublic

Authored by luke on Jun 22 2023, 10:07 AM.

Details

Summary

The current instruction's pointer operand may be different from the one
specified in the Operands argument. We should use the pointer operand
from here instead in case the user has transformed it.

This manifested itself somewhere down the line in
https://reviews.llvm.org/D149889, but I haven't been able to create a
test case on its own yet unfortunately.

Diff Detail

Event Timeline

luke created this revision.Jun 22 2023, 10:07 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 22 2023, 10:07 AM
Herald added subscribers: asb, pmatos. · View Herald Transcript
luke requested review of this revision.Jun 22 2023, 10:07 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 22 2023, 10:07 AM
nikic added a subscriber: nikic.Jun 22 2023, 12:07 PM
nikic added inline comments.
llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
1155

There are more places in here that directly access operands, such as this one. Maybe clean up all of them at once?

luke updated this revision to Diff 533796.Jun 22 2023, 2:57 PM

Update all other uses of getOperand to use Operands argument

luke retitled this revision from [CostModel] Fix GEP pointer operand in getInstructionCost to [CostModel] Use operands argument in getInstructionCost in more places.Jun 22 2023, 2:58 PM
luke added inline comments.Jun 22 2023, 3:00 PM
llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
1258

Note: the logic here still uses the instructions operands, and not the operands argument. But it still seems worthwhile using the argument where we can since the TTI hooks that are ultimately called are passed it. And presumably, that's what they use too.

nikic accepted this revision.Jun 23 2023, 12:25 AM

LGTM

This revision is now accepted and ready to land.Jun 23 2023, 12:25 AM