This is an archive of the discontinued LLVM Phabricator instance.

[ValueTracking] Add tests for deducing non-zero based for incoming phi-edges; NFC
ClosedPublic

Authored by goldstein.w.n on Aug 12 2023, 2:43 PM.

Diff Detail

Event Timeline

goldstein.w.n created this revision.Aug 12 2023, 2:43 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 12 2023, 2:43 PM
Herald added a subscriber: StephenFan. · View Herald Transcript
goldstein.w.n requested review of this revision.Aug 12 2023, 2:43 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 12 2023, 2:43 PM
nikic added inline comments.Aug 13 2023, 1:05 AM
llvm/test/Analysis/ValueTracking/phi-known-nonzero.ll
28

ugeh...

212

Missing test for the equal successor case?

And unless I missed it, there is no test for swapped successors (F, T instead of T, F)?

goldstein.w.n marked an inline comment as done.Aug 13 2023, 10:31 AM
goldstein.w.n added inline comments.
llvm/test/Analysis/ValueTracking/phi-known-nonzero.ll
212

Missing test for the equal successor case?

What do you mean 'equal successor case'?

And unless I missed it, there is no test for swapped successors (F, T instead of T, F)?

eq_non_zero2 and all the *lt/*le cases?
But added a failure case for this as well.

Add some more tests

nikic added inline comments.Aug 14 2023, 3:00 AM
llvm/test/Analysis/ValueTracking/phi-known-nonzero.ll
25

Does just br label %T not work here? I don't think the conditional is needed.

212

What do you mean 'equal successor case'?

br i1 %cmp, label %T, label %T

What do you mean 'equal successor case'?

Oh, I see. You always use br i1 %cmp, label %T, label %F, but in some cases the phi is in %T and in some in %F. Okay, that also works.

goldstein.w.n marked 2 inline comments as done.Aug 14 2023, 9:06 AM
goldstein.w.n added inline comments.
llvm/test/Analysis/ValueTracking/phi-known-nonzero.ll
25

Switched to do that.

212

Switched to the uncond logic.

goldstein.w.n marked 2 inline comments as done.

Fixup br

nikic accepted this revision.Aug 15 2023, 2:08 AM

LGTM, but I think this is still missing a test case for equal successors, something like this:

define i1 @equal_successors(i8 %x) {
entry:
  %cmp = icmp ugt i8 %x, 32
  br i1 %cmp, label %T, label %T
T:
  %v = phi i8 [ %x, %entry], [-1, %F]
  %r = icmp eq i8 %v, 0
  ret i1 %r
}
This revision is now accepted and ready to land.Aug 15 2023, 2:08 AM