This is an archive of the discontinued LLVM Phabricator instance.

[AArch64] Improve cost of umull from known bits
ClosedPublic

Authored by dmgreen on Jul 11 2023, 2:56 AM.

Details

Summary

As in D140287, we can now generate umull from mul(zext(x), y) in cases where we know that the top bits of y are zero. This teaches that to the cost model, adjusting how isWideningInstruction detects mul operations that can extend both operands. This helps for constants and other cases where the operands of the mul are known to be extended, but not directly extends.

Diff Detail

Event Timeline

dmgreen created this revision.Jul 11 2023, 2:56 AM
dmgreen requested review of this revision.Jul 11 2023, 2:56 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 11 2023, 2:56 AM
Herald added a subscriber: wangpc. · View Herald Transcript
dmgreen updated this revision to Diff 539440.Jul 12 2023, 2:33 AM

Fix a typo and update a comment

samtebbs accepted this revision.Jul 12 2023, 3:43 AM

Looks good to me with a couple of questions.

llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
1956–1958

Is checking for i16, i32 and i64 not the same as checking if the elements are at least 16 bits wide? Could we encounter 128 bit here?

1987–1991

Perhaps these two if statements could be combined.

This revision is now accepted and ready to land.Jul 12 2023, 3:43 AM
dmgreen marked an inline comment as done.Jul 12 2023, 5:12 AM

Thanks

llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
1956–1958

Yeah it's aiming to rule out strange types like i23 too, but doing that earlier so we don't get further into this function before realizing we dont have a legal operation for types like those.

1987–1991

Sounds good.

This revision was landed with ongoing or failed builds.Jul 12 2023, 5:13 AM
This revision was automatically updated to reflect the committed changes.
dmgreen marked an inline comment as done.
samtebbs added inline comments.Jul 12 2023, 5:31 AM
llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
1956–1958

Oh right, I didn't know those were possible. That makes a lot of sense.