The signed version of our "magic number" computation for the integer approximation
authorCameron Zwarich <zwarich@apple.com>
Mon, 21 Feb 2011 00:22:02 +0000 (00:22 +0000)
committerCameron Zwarich <zwarich@apple.com>
Mon, 21 Feb 2011 00:22:02 +0000 (00:22 +0000)
commit8d7285d0e5eb5937a6682e884b883516377e903d
treeccf0591dff9fa8874d00e480674cd7e77c84bbdf
parent0b85d07d4611e7d704bf6550fbc624aff36a53b4
The signed version of our "magic number" computation for the integer approximation
of a constant had a minor typo introduced when copying it from the book, which
caused it to favor negative approximations over positive approximations in many
cases. Positive approximations require fewer operations beyond the multiplication.

In the case of division by 3, we still generate code that is a single instruction
larger than GCC's code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126097 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Support/APInt.cpp
lib/Target/X86/README.txt
test/CodeGen/X86/divide-by-constant.ll
unittests/ADT/APIntTest.cpp