[x86] promote all multiply i8 by constant to i32
authorSanjay Patel <spatel@rotateright.com>
Mon, 26 Nov 2018 15:22:30 +0000 (15:22 +0000)
committerSanjay Patel <spatel@rotateright.com>
Mon, 26 Nov 2018 15:22:30 +0000 (15:22 +0000)
commitd31220e0de0d8924e7c1f54d08d4515cfabb1aeb
treeaf6020d43e16d902f8b483a5d0a5b94dc2ea150e
parent2447baff848ec8bcb74575ed686a776fbfd1b8cc
[x86] promote all multiply i8 by constant to i32

We have these 2 "isDesirable" promotion hooks (I'm not sure why we need both of them, but that's
independent of this patch), and we can adjust them to promote "mul i8 X, C" to i32. Then, all of
our existing LEA and other multiply expansion magic happens as it would for i32 ops.

Some of the test diffs show that we could end up with an actual 32-bit mul instruction here
because we choose not to expand to simpler ops. That instruction could be slower depending on the
subtarget. On the plus side, this means we don't need a separate instruction to load the constant
operand and possibly an extra instruction to move the result. If we need to tune mul i32 further,
we could add a later transform that tries to shrink it back to i8 based on subtarget timing.

I did not bother to duplicate all of the 32-bit test file RUNs and target settings that exist to
test whether LEA expansion is cheap or not. The diffs here assume a default target, so that means
LEA is generally cheap.

Differential Revision: https://reviews.llvm.org/D54803

llvm-svn: 347557
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/test/CodeGen/X86/ipra-reg-alias.ll
llvm/test/CodeGen/X86/load-scalar-as-vector.ll
llvm/test/CodeGen/X86/mul-constant-i8.ll
llvm/test/CodeGen/X86/urem-i8-constant.ll