[PATCH] D27749: [APFloat] Fix rotl/rotr when the shift amount is greater than the total bit width.

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 5 11:04:55 PST 2017


efriedma added a comment.

> Should the APInt rotateAmt need to have the same bitwidth as the APInt the rotl is being called on?

I don't see any reason to add that restriction.  (Please add a test for this.)

----

Please add a testcase for a very large rotate amount (greater than 2^64).  Please add testcases for rotating an integer whose bit-width is not a power of two.



================
Comment at: lib/Support/APInt.cpp:1249
+  unsigned rotBitWidth = rotateAmt.getBitWidth();
+  APInt rem(rotateAmt.urem(APInt(rotBitWidth, BitWidth)));
+  return rotl((unsigned)rem.getLimitedValue(BitWidth));
----------------
"APInt(rotBitWidth, BitWidth)" could be zero.  (For example, `APInt(32, 1).rotl(APInt(1, 1))`.  Please add this as a testcase.)


Repository:
  rL LLVM

https://reviews.llvm.org/D27749





More information about the llvm-commits mailing list