This is an archive of the discontinued LLVM Phabricator instance.

[TargetLowering] Better code generation for ISD::SADDSAT/SSUBSAT when operand sign is known
ClosedPublic

Authored by 0xdc03 on Jun 22 2023, 10:13 AM.

Details

Summary

When the sign of either of the operands is known, it is possible to
determine what the saturating value will be without having to compute it
using the sign bits.

Diff Detail

Event Timeline

0xdc03 created this revision.Jun 22 2023, 10:13 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 22 2023, 10:13 AM
0xdc03 requested review of this revision.Jun 22 2023, 10:13 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 22 2023, 10:13 AM

Looks reasonable to me.

llvm/test/CodeGen/AArch64/aarch64-saturating-arithmetic.ll
2

You can drop -verify-machineinstrs, -O3 and --check-prefixes=CHECK here. -verify-machineinstrs is enabled under EXPENSIVE_CHECKS, and doesn't need to be added to most tests. -O3 rarely differs from the default of -O2 for llc. --check-prefixes=CHECK is already the default.

209

Can you please commit the tests with baseline checks and then rebase the patch over that? See https://llvm.org/docs/TestingGuide.html#precommit-workflow-for-tests.

The (AArch64) tests all seem to be correct.

0xdc03 updated this revision to Diff 533882.Jun 23 2023, 12:53 AM
  • Address reviewer comments, rebase on top of pre-committed test
0xdc03 added inline comments.Jun 23 2023, 12:54 AM
llvm/test/CodeGen/AArch64/aarch64-saturating-arithmetic.ll
2

Done! Thanks for the information, I had just copied the RUN line from the adjacent test file: aarch64-pmull2.ll

209

Done!

nikic accepted this revision.Jun 23 2023, 12:58 AM

LGTM

This revision is now accepted and ready to land.Jun 23 2023, 12:58 AM
This revision was landed with ongoing or failed builds.Jun 23 2023, 12:59 AM
This revision was automatically updated to reflect the committed changes.