This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Share reduction lowering code for vp.reduce
ClosedPublic

Authored by reames on Dec 9 2022, 11:21 AM.

Details

Summary

We can consolidate code and clarify edge case behavior at the same time.

There are two functional differences here.

First, I remove the ResVT handling, and always use the reduction element type. This appears to be dead code. There's no test coverage, and I think such a construct wouldn't be legal anyways. This is the main reason I posted this for review as I want someone to double check me on this point.

Second, if the VL happens to be known non-zero, we can avoid passing through start. This is mostly needed to allow reuse of the existing code; I don't consider it interesting as an optimization on it's own.

Diff Detail

Event Timeline

reames created this revision.Dec 9 2022, 11:21 AM
reames requested review of this revision.Dec 9 2022, 11:21 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 9 2022, 11:21 AM

First, I remove the ResVT handling, and always use the reduction element type. This appears to be dead code. There's no test coverage, and I think such a construct wouldn't be legal anyways. This is the main reason I posted this for review as I want someone to double check me on this point.

EXTRACT_VECTOR_ELT is allowed to have a scalar result type larger than the element type. BUILD_VECTOR, SPLAT_VECTOR, and INSERT_VECTOR_ELT can have a scalar argument larger than the element type of the vector. This is required by type legalization since the legal scalar types may be larger than the legal vector element types.

I think the VPREDUCE expansion may have been happening during LegalizeDAG when this was written. That would require any scalar types created to be legal. I think it is called during LegalizeVectorOps now and there is a scalar type legalization pass between LegalizeVectorOps and LegalizeDAG.

This revision is now accepted and ready to land.Dec 9 2022, 11:44 AM
This revision was landed with ongoing or failed builds.Dec 9 2022, 12:23 PM
This revision was automatically updated to reflect the committed changes.