[X86ISelLowering] Add additional support for multiplication-to-shift conversion.
authorChen Li <meloli87@gmail.com>
Sat, 12 Dec 2015 01:04:15 +0000 (01:04 +0000)
committerChen Li <meloli87@gmail.com>
Sat, 12 Dec 2015 01:04:15 +0000 (01:04 +0000)
commitf99bcae76f160415bfae61e9b20ffde66d045b4a
treea39483d7dc19618f33d74e425a7bd56deb9105c9
parent9bc6874751243505aa43af6cf6d66d86eb9f7bdc
[X86ISelLowering] Add additional support for multiplication-to-shift conversion.

Summary: This patch adds support of conversion (mul x, 2^N + 1) => (add (shl x, N), x) and (mul x, 2^N - 1) => (sub (shl x, N), x) if the multiplication can not be converted to LEA + SHL or LEA + LEA. LLVM has already supported this on ARM, and it should also be useful on X86. Note the patch currently only applies to cases where the constant operand is positive, and I am planing to add another patch to support negative cases after this.

Reviewers: craig.topper, RKSimon

Subscribers: aemerson, llvm-commits

Differential Revision: http://reviews.llvm.org/D14603

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255415 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/X86/X86ISelLowering.cpp
test/CodeGen/X86/imul.ll