[PATCH] D26890: SHA1: unroll loop in hashBlock.

Mehdi AMINI via llvm-commits llvm-commits at lists.llvm.org
Sat Nov 19 16:57:01 PST 2016


mehdi_amini added inline comments.


================
Comment at: lib/Support/SHA1.cpp:82
+  B = rol(B, 30);
+}
+
----------------
ruiu wrote:
> mehdi_amini wrote:
> > Please use static free function if there is no need to access the state of the object.
> blk and blk0 access InternalState, so these functions need to be members.
Sure, but you could have an extra arg to access the buffer, like:

```
uint32_t SHA1::blk(int I, uint32_t* Buffer) {
  Buffer[I & 15] = rol(
      Buffer[(I + 13) & 15] ^
          Buffer[(I + 8) & 15] ^
          Buffer[(I + 2) & 15] ^ Buffer[I & 15],
      1);
  return Buffer[I & 15];
}
```


https://reviews.llvm.org/D26890





More information about the llvm-commits mailing list