[PATCH] D15496: [InstCombine] Identify partial bitreverses

Sanjoy Das via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 17 13:25:25 PST 2016


sanjoy added inline comments.

================
Comment at: lib/Transforms/InstCombine/InstCombineAndOrXor.cpp:1765
@@ +1764,3 @@
+  for (int i = 0, e = BitValues.size(); i != e; ++i) {
+    if (BitProvenance[i] == -1 || BitProvenance[i] == i) {
+      IgnoreMask.setBit(i);
----------------
> In a partial bitreverse/bswap, some of the bits are going to be the same as the original value. We're essentially saying that the result is a OR-ed mask of a reversed value and the original value:

Right, and I don't see where you're creating that OR -- all I see is the `bitreverse(a) & ~M` part.  If I understand the scheme correctly and am not misreading the code, you'll have to keep two masks -- `IgnoreMask` (set if `BitProvenance[i] == -1`) and `IdentityMask` (set if `BitProvenance[i] == i`), and then return `bitreverse(a) & ~IgnoreMask | a & IdentityMask`.

(I assume `BitProvenance[i] == -1` means "bit `i` is always `0` in the output"?)


Repository:
  rL LLVM

http://reviews.llvm.org/D15496





More information about the llvm-commits mailing list