This is an archive of the discontinued LLVM Phabricator instance.

[ConstraintElim] Store conditional facts as (Predicate, Op0, Op1).
ClosedPublic

Authored by fhahn on Aug 25 2023, 4:28 AM.

Details

Summary

This allows to add facts even if no corresponding ICmp instruction
exists in the IR.

Diff Detail

Event Timeline

fhahn created this revision.Aug 25 2023, 4:28 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 25 2023, 4:28 AM
fhahn requested review of this revision.Aug 25 2023, 4:28 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 25 2023, 4:28 AM
nikic added inline comments.Aug 28 2023, 7:16 AM
llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
120

The flags here have become something of a mess. Can we represent these as an enum instead? Something like...

enum {
  /// Fact implied by Inst, holds from the definition point of Inst.
  InstFact,
  /// Fact implied by Condition, holds from the start of the block.
  CondFact,
  /// Check at a specific use-site of an instruction.
  UseCheck,
  /// Check for all uses of an instruction.
  InstCheck,
}

...assuming those are the possible cases, of which I'm not really sure.

fhahn updated this revision to Diff 554304.Aug 29 2023, 6:53 AM
fhahn marked an inline comment as done.

Rebase on top of e6260ec49c5d16dc93ebe8b.

fhahn added inline comments.Aug 29 2023, 6:58 AM
llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
120

Thanks, added an enum here: e6260ec49c5d

nikic accepted this revision.Aug 29 2023, 7:11 AM

LGTM

llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
1415

I think you can directly << Pred nowadays.

1418

You can pass false to avoid printing the type again.

1460

I feel like this code would be simpler/cleaner if you didn't share this AddFact call and just did it in both branches above.

This revision is now accepted and ready to land.Aug 29 2023, 7:11 AM
This revision was landed with ongoing or failed builds.Aug 30 2023, 2:55 AM
This revision was automatically updated to reflect the committed changes.
fhahn marked 3 inline comments as done.Aug 30 2023, 3:00 AM
fhahn added inline comments.
llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
1415

Nice, updated in the committed version, thanks!

1418

Nice, updated in the committed version, thanks!

1460

Add fact can be used unconditionally here. Also simplified the matching for the assume condition and added an assert that it gets matched.