This is an archive of the discontinued LLVM Phabricator instance.

[DAG] Calculate the number of sign bits for constant BUILD_VECTOR directly.
ClosedPublic

Authored by dmgreen on May 5 2023, 6:33 AM.

Details

Summary

For constant BUILD_VECTORs the operands need to be legal types. This can mean that when the number of sign bits is calculated it may look that the entire constant and inefficiently produce less sign bits than it could. For example i8 vectors could use i32 elements, for which 0x000000ff would be incorrectly limited to 1 sign bit as the original value has 24 sign bits. This makes it look at the constant directly, truncated to the correct type for the element so that it can correctly return 8.

Diff Detail

Event Timeline

dmgreen created this revision.May 5 2023, 6:33 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 5 2023, 6:33 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
dmgreen requested review of this revision.May 5 2023, 6:33 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 5 2023, 6:33 AM
RKSimon accepted this revision.May 5 2023, 6:52 AM

Makes sense - we could go further and use ComputeKnownBits on the element whenever there is implicit truncation and chose between it and the ComputeNumSignBits call - but this is probably good enough in most cases.

This revision is now accepted and ready to land.May 5 2023, 6:52 AM
This revision was landed with ongoing or failed builds.May 7 2023, 2:31 PM
This revision was automatically updated to reflect the committed changes.