This is an archive of the discontinued LLVM Phabricator instance.

[NFC][ValueTracking]: Move some code from isKnownNonZero to isKnownNonZeroFromOperator
ClosedPublic

Authored by 0xdc03 on Jul 24 2023, 10:11 AM.

Details

Summary

There is some pointer simplification code originally from isKnownNonNull
that is now better suited to be in isKnownNonZeroFromOperator.

Diff Detail

Event Timeline

0xdc03 created this revision.Jul 24 2023, 10:11 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 24 2023, 10:11 AM
0xdc03 requested review of this revision.Jul 24 2023, 10:11 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 24 2023, 10:11 AM

No complaints about the code, but just curious whats the rationale? Why is isKnownNonZeroFromOperator a better home?

No complaints about the code, but just curious whats the rationale? Why is isKnownNonZeroFromOperator a better home?

For AllocaInst, isKnownNonZeroFromOperator now holds the big switch with all the instruction types so it makes more sense to me for it to be in there.

For CallBase, I think it is better if the code is combined with the rest of the CallInst handling that is already there.

nikic added inline comments.Jul 25 2023, 1:13 AM
llvm/lib/Analysis/ValueTracking.cpp
2459–2461

Alloca always returns a pointer.

2696

Should add case Instruction::Invoke: here as well.

2697

Can be cast<>. We should probably also guard this against I->getType()->isPointerTy().

0xdc03 updated this revision to Diff 543936.Jul 25 2023, 5:40 AM
  • Address reviewer comments
0xdc03 marked 3 inline comments as done.Jul 25 2023, 5:40 AM
This revision is now accepted and ready to land.Jul 25 2023, 5:52 AM
This revision was landed with ongoing or failed builds.Jul 26 2023, 1:29 AM
This revision was automatically updated to reflect the committed changes.