This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Use reduction result type for EXTRACT_VECTOR_ELT in lowerReductionSeq.
ClosedPublic

Authored by craig.topper on Dec 9 2022, 5:13 PM.

Details

Summary

Remove the call to getSExtOrTrunc.

Reduction ISD nodes produce a scalar result and that result is
allowed to be larger than the vector element type due to type
legalization. This is the same rule we allow for EXTRACT_VECTOR_ELT
for the same reason.

We can copy the result type over from the reduction node to
EXTRACT_VECTOR_ELT.

Diff Detail

Event Timeline

craig.topper created this revision.Dec 9 2022, 5:13 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 9 2022, 5:13 PM
craig.topper requested review of this revision.Dec 9 2022, 5:13 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 9 2022, 5:13 PM
reames accepted this revision.Dec 12 2022, 9:06 AM

LGTM, but with a question to make sure of my understanding.

Are you sure that the interpretation of a reduction with a wider type is as a sext? It needs to be to match the code you're removing, but it could in principle be a zext or aext. Can you point to something in the code to demonstrate it must be sext? Or alternatively, explain why aext is okay?

This revision is now accepted and ready to land.Dec 12 2022, 9:06 AM

LGTM, but with a question to make sure of my understanding.

Are you sure that the interpretation of a reduction with a wider type is as a sext? It needs to be to match the code you're removing, but it could in principle be a zext or aext. Can you point to something in the code to demonstrate it must be sext? Or alternatively, explain why aext is okay?

If the result type is wider than the element type, the semantics of the reduction node we're lowering is aext. Same with EXTRACT_VECTOR_ELT. I don't think we were obligated to use a sext here.