This is an archive of the discontinued LLVM Phabricator instance.

[NFC] Add baseline tests for int isKnownNonZero
ClosedPublic

Authored by dlrobertson on Apr 19 2019, 7:26 PM.

Details

Summary

Add baseline tests for improvements of isKnownNonZero for integer types.

Diff Detail

Repository
rL LLVM

Event Timeline

dlrobertson created this revision.Apr 19 2019, 7:26 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 19 2019, 7:26 PM
nikic added inline comments.Apr 22 2019, 8:57 AM
llvm/test/Transforms/InstCombine/cttz.ll
31 ↗(On Diff #195958)

It would be good to also test the ctlz case here. Possibly with a vector type, so we have at least one test that checks this transform with a vector zero.

spatel accepted this revision.Apr 22 2019, 9:01 AM

Sorry, I didn't notice the patch stack before commenting in D60846.

LGTM - but I agree with the earlier comment about adding 1 more test for extra coverage.

This revision is now accepted and ready to land.Apr 22 2019, 9:01 AM
nikic added a comment.Apr 22 2019, 9:09 AM

Probably also a good time to request commit access, see https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access for instructions.

dlrobertson marked an inline comment as done.Apr 22 2019, 11:22 AM

Probably also a good time to request commit access, see https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access for instructions.

Will do!

llvm/test/Transforms/InstCombine/cttz.ll
31 ↗(On Diff #195958)

+1 sounds good

dlrobertson marked an inline comment as not done.Apr 24 2019, 5:24 PM
dlrobertson added inline comments.
llvm/test/Transforms/InstCombine/cttz.ll
31 ↗(On Diff #195958)

After looking at this, I'm not sure how this would work. The input value x would be a vector, but you can not br on a vector of i1s

nikic added inline comments.Apr 24 2019, 11:49 PM
llvm/test/Transforms/InstCombine/cttz.ll
31 ↗(On Diff #195958)

That's a good point! I guess vectors are indeed not subject to this transform, at least not without additional handling (we'd have to recognize an "all elements zero" pattern for the branch condition.)

In that case it might make sense to add an early exit for vector types in the main patch to avoid unnecessary walking the uses.

lebedev.ri added inline comments.
llvm/test/Transforms/InstCombine/cttz.ll
31 ↗(On Diff #195958)

%t0 = bitcast <8 x i1> to i8
icmp eq i8 %t0, 0

nikic added inline comments.Apr 25 2019, 12:05 AM
llvm/test/Transforms/InstCombine/cttz.ll
31 ↗(On Diff #195958)

@lebedev.ri Thanks! I'm not sure whether it's worthwhile to add handling for this, as it would require walking uses three levels deep (uses of the original value, uses of the bitcast, uses of the icmp). It wouldn't hurt to add a test for it though, even if it'll not be handled by this patch.

dlrobertson marked an inline comment as done.Apr 25 2019, 4:38 AM
dlrobertson added inline comments.
llvm/test/Transforms/InstCombine/cttz.ll
31 ↗(On Diff #195958)

%t0 = bitcast <8 x i1> to i8
icmp eq i8 %t0, 0

awesome! I'll add a test with this

In that case it might make sense to add an early exit for vector types

Good point. I'll add that

This revision was automatically updated to reflect the committed changes.

I followed the https://llvm.org/docs/Phabricator.html#committing-a-change section for the commit. If I made a mistake, please let me know.