This is an archive of the discontinued LLVM Phabricator instance.

[VPlan] Replace CalculateTripCountMinusVF with existing VPInstructions (WIP).
Needs ReviewPublic

Authored by fhahn on Aug 8 2023, 8:10 AM.

Details

Reviewers
gilr
Ayal
rengolin
Summary

Building on the added RuntimeVFxUF, replace the CalculateTripCountMinusVF
opcode with explicit Sub,Cmp & Select VPInstructions to compute the trip
count minus 1. This removes a very specific opcode and allows re-using
the already computed VFxUF.

Note that this highlights an existing challenge with using VPInstruction to
model computation in the vector preheaders: when using VPInstruction to
compute scalar values outside a vector loop, we may have to explicitly
access VPIteration(0, 0) when retrieving the corresponding value from
state.

The reason for that is that some recipes in the preheader must
explicitly set VPIteration(0, 0) because some of their users in the
vector loop may need to access a vector with lane 0 broadcasted (e.g.
trip count for tail folding top-level mask compare). For now this patch
works around this by checking if the VPInstruction has a parent region.
Should we generalize this for all opcodes in generateInstruction?

Note: A number of tests still need updating.

Depends on D157322.

Diff Detail

Event Timeline

fhahn created this revision.Aug 8 2023, 8:10 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 8 2023, 8:10 AM
fhahn requested review of this revision.Aug 8 2023, 8:10 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 8 2023, 8:10 AM
Herald added subscribers: wangpc, vkmr. · View Herald Transcript
fhahn retitled this revision from [VPlan] Replace CalculateTripCountMinusVF with explicit VPInstructions (WIP). to [VPlan] Replace CalculateTripCountMinusVF with existing VPInstructions (WIP)..Aug 8 2023, 8:11 AM