This is an archive of the discontinued LLVM Phabricator instance.

[ValueTracking] Add logic for tracking lowbit of (and/xor/or X, (add/sub X, Odd))
ClosedPublic

Authored by goldstein.w.n on Jan 23 2023, 5:38 PM.

Details

Summary

Any case of logicop + add/sub(Odd) we can prove the low bit is either
zero/non-zero.

Alive2 Links:

xor:
    sub x, C: https://alive2.llvm.org/ce/z/aaABdS
    sub C, x: https://alive2.llvm.org/ce/z/2W-ZJ7
    add C, x: https://alive2.llvm.org/ce/z/pzDkte
or:
    sub x, C: https://alive2.llvm.org/ce/z/xd-bcP
    sub C, x: https://alive2.llvm.org/ce/z/p8hXJF
    add C, x: https://alive2.llvm.org/ce/z/osmkB6
and:
    sub x, C: https://alive2.llvm.org/ce/z/D_NNxR
    sub C, x: https://alive2.llvm.org/ce/z/N_5C62
    add C, x: https://alive2.llvm.org/ce/z/4cy7a4

Diff Detail

Event Timeline

goldstein.w.n created this revision.Jan 23 2023, 5:38 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 23 2023, 5:38 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
goldstein.w.n requested review of this revision.Jan 23 2023, 5:38 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 23 2023, 5:38 PM

Make and/xor/or helper public

Rebase and use blsi/blsmsk api

Rebase + apply changes from D142271

Can you please split this into an NFC patch that splits off analyzeKnownBitsFromAndXorOr() without changing logic, and then one that implements the new folds? (D142429 could be based on either one.)

Rebase after splitting

Can you please split this into an NFC patch that splits off analyzeKnownBitsFromAndXorOr() without changing logic, and then one that implements the new folds? (D142429 could be based on either one.)

Done see D142849

nikic added a comment.Feb 20 2023, 1:12 AM

It looks like the tests have coverage for the newly added or/xor with add cases -- but this patch also adds sub cases that don't have any corresponding test change? Either the sub cases should be dropped, or they should be tested.

It looks like the tests have coverage for the newly added or/xor with add cases -- but this patch also adds sub cases that don't have any corresponding test change? Either the sub cases should be dropped, or they should be tested.

Added new tests to cover all new cases. Removed some of the less useful existing tests.

nikic accepted this revision.Feb 20 2023, 11:51 AM

LGTM

This revision is now accepted and ready to land.Feb 20 2023, 11:51 AM
This revision was landed with ongoing or failed builds.Feb 23 2023, 5:52 PM
This revision was automatically updated to reflect the committed changes.