[PATCH] D51325: [X86] Type legalize v2i32 div/rem by scalarizing rather than promoting

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 27 14:32:00 PDT 2018


craig.topper created this revision.
craig.topper added reviewers: RKSimon, spatel.

Previously we type legalized v2i32 div/rem by promoting to v2i64. But we don't support div/rem of vectors so op legalization would then scalarize it using i64 scalar ops since it doesn't know about the original promotion. 64-bit scalar divides on Intel hardware are known to be slow and in 32-bit mode they require a libcall.

This patch switches type legalization to do the scalarizing itself using i32.

It looks like the division by power of 2 optimization is still kicking in and leaving the code as a vector. The division by other constant optimization doesn't kick in pre type legalization since it ignores illegal types. And previously, after type legalization we scalarized the v2i64 since we don't have v2i64 MULHS/MULHU support.

Another option might be to widen v2i32 to v4i32 so we could do division by constant optimizations, but we'd have to be careful to only do that for constant divisors or we risk scalaring to 4 scalar divides.


https://reviews.llvm.org/D51325

Files:
  lib/Target/X86/X86ISelLowering.cpp
  test/CodeGen/X86/scalar_widen_div.ll
  test/CodeGen/X86/vector-idiv-v2i32.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51325.162748.patch
Type: text/x-patch
Size: 28991 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180827/3392bb1c/attachment.bin>


More information about the llvm-commits mailing list