[PATCH] D34029: Infer lowest bits of an integer Multiply when the low bits of the operands are known

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 18 11:04:02 PDT 2017


efriedma added a comment.

> I tried to figure out how this could be improved, and considered your idea of leading zeros. I think I understood what you were thinking, but while trying to figure out the math I couldn't see how it would be possible. Having an extra leading known-zero on one of the operands over another operand would not help to figure out more digits, as far as I could see.

Trailing zeros, not leading zeros.

Suppose you have multiply operands "a" and "b".  The bottom three bits of "a" are 110, and the bottom two bits of "b" are 11.  "a" is divisible by 2, so "a * b == 2 * ((a / 2) * b)".  The bottom two bits of "a / 2" are 11, and the bottom two bits of "b" are 11, so the bottom two bits of "(a / 2) * b" are "01".  Therefore the bottom three bits of "2 * ((a / 2) * b)" are "010".


https://reviews.llvm.org/D34029





More information about the llvm-commits mailing list