This is an archive of the discontinued LLVM Phabricator instance.

[ConstantRange] Construct constant range from xor operation
Needs ReviewPublic

Authored by Joe on Feb 18 2022, 8:36 AM.

Details

Reviewers
nikic
fhahn
Summary

Retains information when two constant ranges are xor'd together. This is
only possible if both constant ranges do not range over signage.

Diff Detail

Event Timeline

Joe created this revision.Feb 18 2022, 8:36 AM
Joe requested review of this revision.Feb 18 2022, 8:36 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 18 2022, 8:36 AM
Joe updated this revision to Diff 409948.Feb 18 2022, 8:39 AM

Fix malformed diff.

Joe updated this revision to Diff 409952.Feb 18 2022, 8:41 AM
Joe retitled this revision from [VRP] Construct constant range from xor operation to [ConstantRange] Construct constant range from xor operation.Feb 18 2022, 8:45 AM
Joe added reviewers: nikic, fhahn.
Joe added a subscriber: mohammed-nurulhoque.
nikic added inline comments.Feb 18 2022, 9:22 AM
llvm/lib/IR/ConstantRange.cpp
1428

I don't understand how signedness is relevant here. Can't you use Lower and Upper-1 here, independent of signedness?

llvm/unittests/IR/ConstantRangeTest.cpp
2531

Please add an exhaustive correctness test.

Joe updated this revision to Diff 410280.Feb 21 2022, 5:04 AM
Joe marked an inline comment as done.

Add exhaustive correctness test.
Also remove signage test in binaryXor, as the common bits would be 0 anyway, thus creating a full set regardless.

llvm/lib/IR/ConstantRange.cpp
1428

The call to getSignedMin/Max includes a check of isFullSet and isUpperSignWrapped, which is relevant here, otherwise Upper-1 would not work.

Herald added a project: Restricted Project. · View Herald TranscriptMar 7 2022, 2:03 AM