This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] cttz(-x) -> cttz(x)
ClosedPublic

Authored by xbolva00 on Jun 18 2019, 5:39 PM.

Details

Summary

Signedness does not change number of trailing zeros.

Diff Detail

Event Timeline

xbolva00 created this revision.Jun 18 2019, 5:39 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 18 2019, 5:39 PM
xbolva00 updated this revision to Diff 205565.EditedJun 19 2019, 6:03 AM

Rebased, added tests.

xbolva00 updated this revision to Diff 205573.Jun 19 2019, 6:47 AM

Uploaded correct patch.

Is 'nsw' a requirement? If not, the tests should not include that, or at least not *all* of the tests should include that.

The latest version of Alive can verify this, but not the online version?

xbolva00 added a comment.EditedJun 19 2019, 8:49 AM

I built z3 and Alive2 trunks for Ubuntu 18.04

I took example
Name: cttz constant
%r = cttz i8 32, i1 0

=>

%r = 5

~/alive2/build$ ./alive -root-only c.opt
Processing c.opt..

It never stops..

Edit: I tried 4.8.1 too. Alive2's master branch broken?

xbolva00 edited the summary of this revision. (Show Details)Jun 19 2019, 11:07 AM
spatel accepted this revision.Jun 20 2019, 6:10 AM

LGTM

test/Transforms/InstCombine/cttz-negative.ll
19–20 ↗(On Diff #205612)

It would be better if at least 1 of these tests showed an extra use of the negated value. That would verify that we still do the transform independently of uses of that value.

This revision is now accepted and ready to land.Jun 20 2019, 6:10 AM
xbolva00 updated this revision to Diff 205850.Jun 20 2019, 9:57 AM

Added "multi use" test.

This revision was automatically updated to reflect the committed changes.