[PATCH] D68672: [APInt] Rounding right-shifts
Roman Lebedev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 8 16:36:59 PDT 2019
lebedev.ri created this revision.
lebedev.ri added reviewers: sanjoy, nikic, craig.topper, RKSimon.
lebedev.ri added a project: LLVM.
Herald added subscribers: dexonsmith, hiraditya.
lebedev.ri added a reviewer: timshen.
lebedev.ri marked an inline comment as done.
lebedev.ri added a subscriber: timshen.
lebedev.ri added inline comments.
================
Comment at: llvm/unittests/ADT/APIntTest.cpp:2529-2538
+ EXPECT_TRUE(Prod.sge(A));
+ if (Prod.sgt(A)) {
EXPECT_TRUE(((Quo - 1).sext(16) * B.sext(16)).ult(A));
}
}
{
APInt Quo = APIntOps::RoundingSDiv(A, B, APInt::Rounding::DOWN);
----------------
@sanjoy @timshen FIXME: that's the intended check, right?
There's already rounding division, which is used in `ConstantRange` to
implement e.g. `makeExactMulNUWRegion()`/`makeExactMulNUWRegion()`
but there are no versions for right-shifts.
I'd like to try to extend `ConstantRange::makeGuaranteedNoWrapRegion()`
to deal with `Instruction::Shl` so i believe i need rounding right shifts.
The test coverage is confusing.
The existing `RoundingSDiv()` didn't actually pass - it never runs.
I've fixed that, and adjusted it to pass - i think we should be checking signed predicates?
Then i've added `APIntOps::RoundingLShr()`, `APIntOps::RoundingAShr()`,
standalone test coverage for them, and a cross-test to verify that
they produce identical output as compared to their `div` friends.
They do.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D68672
Files:
llvm/include/llvm/ADT/APInt.h
llvm/lib/Support/APInt.cpp
llvm/unittests/ADT/APIntTest.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68672.223959.patch
Type: text/x-patch
Size: 6905 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191008/a94ce24e/attachment.bin>
More information about the llvm-commits
mailing list