This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Optimize sign-extended EXTRACT_VECTOR_ELT nodes
ClosedPublic

Authored by frasercrmck on Jan 30 2021, 9:28 AM.

Details

Summary

This patch custom-legalizes all integer EXTRACT_VECTOR_ELT nodes where
SEW < XLEN to VMV_S_X nodes to help the compiler infer sign bits from
the result. This allows us to eliminate redundant sign extensions.

For parity, all integer EXTRACT_VECTOR_ELT nodes are legalized this way
so that we don't need TableGen patterns for some and not others.

Diff Detail

Event Timeline

frasercrmck created this revision.Jan 30 2021, 9:28 AM
frasercrmck requested review of this revision.Jan 30 2021, 9:28 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 30 2021, 9:28 AM

Would it still work if we let scalar types promote using the default type legalization and instead just Custom handle the vector type and change the opcode from LegalizeDAG?

Would it still work if we let scalar types promote using the default type legalization and instead just Custom handle the vector type and change the opcode from LegalizeDAG?

From what I could see, no: the type-legalized sign_extend_inreg node is expanded to shl/sra before the extract_vector_elt node. I think at that point we're unable to do much. Does that sound reasonable to you?

  • rebase on top of @craig.topper's recent changes
  • simplify wrt the above
This revision is now accepted and ready to land.Feb 4 2021, 12:00 PM
This revision was landed with ongoing or failed builds.Feb 5 2021, 2:12 AM
This revision was automatically updated to reflect the committed changes.