[PATCH] D57841: [x86] narrow 256-bit horizontal ops via demanded elements

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 6 12:58:33 PST 2019


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

256-bit horizontal math ops are an x86 monstrosity (and thankfully have not been extended to 512-bit AFAIK).

The two 128-bit halves operate on separate halves of the inputs. So if we don't demand anything in the upper half of the result, we can extract the low halves of the inputs, do the math, and then insert that result into a 256-bit output.

All of the extract/insert is free (ymm<-->xmm), so we're left with a narrower (cheaper) version of the original op.

In the affected tests based on:
https://bugs.llvm.org/show_bug.cgi?id=33758
https://bugs.llvm.org/show_bug.cgi?id=38971
...we see that the h-op narrowing can result in further narrowing of other math via existing generic transforms.

I originally drafted this patch as an exact pattern match starting from extract_vector_elt, but I thought we might see diffs starting from extract_subvector too, so I changed it to a more general demanded elements solution. There are no extra existing regression test improvements from that switch though, so we could go back. The patch is slightly less code this way though assuming I didn't miss any constraints.


https://reviews.llvm.org/D57841

Files:
  lib/Target/X86/X86ISelLowering.cpp
  test/CodeGen/X86/haddsub.ll
  test/CodeGen/X86/phaddsub-extract.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57841.185618.patch
Type: text/x-patch
Size: 6647 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190206/5ba7bf1f/attachment.bin>


More information about the llvm-commits mailing list