[PATCH] D54803: [x86] promote all multiply i8 by constant to i32

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 21 08:35:57 PST 2018


spatel created this revision.
spatel added reviewers: craig.topper, RKSimon, lebedev.ri.
Herald added a subscriber: mcrosier.

This is an alternative implementation of where https://reviews.llvm.org/D54770 would likely end up, so I'll abandon that if this is preferred.

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.


https://reviews.llvm.org/D54803

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54803.174934.patch
Type: text/x-patch
Size: 19839 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181121/205847fb/attachment.bin>


More information about the llvm-commits mailing list