This is an archive of the discontinued LLVM Phabricator instance.

[NFC][ValueTracking]: Remove redundant computeKnownBits call for LoadInst in isKnownNonZero
ClosedPublic

Authored by 0xdc03 on Jul 21 2023, 7:55 AM.

Details

Summary

For load instructions, computeKnownBits only checks the range metadata.
This check is already present in isKnownNonZero, so there is no need to
fall through to computeKnownBits.

This change gives a speed improvement of 0.18%:
https://llvm-compile-time-tracker.com/compare.php?from=3c6ed559e5274307995586c1499a2c8e4e0276a0&to=78b462d8c4ae079638b728c6446da5999c4ee9f8&stat=instructions:u

Diff Detail

Event Timeline

0xdc03 created this revision.Jul 21 2023, 7:55 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 21 2023, 7:55 AM
0xdc03 requested review of this revision.Jul 21 2023, 7:55 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 21 2023, 7:55 AM
nikic added inline comments.Jul 21 2023, 7:58 AM
llvm/lib/Analysis/ValueTracking.cpp
2545–2546

It would be good to move this check into the load switch case.

0xdc03 updated this revision to Diff 542924.Jul 21 2023, 8:10 AM
  • Address reviewer comments
llvm/lib/Analysis/ValueTracking.cpp
2545–2546

Done, though I do wonder why this was originally put here. I guess it is a relic from the merge of isKnownNonNull and isKnownNonZero that was never updated.

0xdc03 added inline comments.Jul 21 2023, 8:13 AM
llvm/lib/Analysis/ValueTracking.cpp
2547

For that matter, I guess this could also be moved into the call instruction case?

goldstein.w.n added inline comments.
llvm/lib/Analysis/ValueTracking.cpp
2795

"handled above"? "Handled there"?

nikic accepted this revision.Jul 22 2023, 1:07 AM

LGTM

llvm/lib/Analysis/ValueTracking.cpp
2547

Yes, it would make sense to move all the handling here (apart from Argument).

This revision is now accepted and ready to land.Jul 22 2023, 1:07 AM
0xdc03 added inline comments.Jul 22 2023, 8:01 AM
llvm/lib/Analysis/ValueTracking.cpp
2512

@goldstein.w.n I was referring to this.

0xdc03 updated this revision to Diff 543198.Jul 22 2023, 8:51 AM
  • Rebase on main