[PATCH] D21899: [InstCombine] extend (select X, C1, C2 --> ext X) to vectors

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 30 10:30:00 PDT 2016


spatel created this revision.
spatel added reviewers: eli.friedman, majnemer, hfinkel.
spatel added a subscriber: llvm-commits.
Herald added a subscriber: mcrosier.

The code change is hopefully straightforward: replace dyn_casts with m_APInt, and we get transforms for splat vectors.

But these transforms raise some questions:
1. In the cases where we need a 'not', we're increasing the instruction count. Is this justified because ext/not is always assumed cheaper/more canonical than a select?

2. In the not+zext case, notice that the zext gets moved ahead of the xor. This is because visitZext() has:
  // zext (xor i1 X, true) to i32  --> xor (zext i1 X to i32), 1
There's no code comment for the motivation. Assuming there is good reason to break the m_Not pattern should sext+xor do the same?

3. If we're ok with increasing the instruction count for #1, is the scalar select of vectors example also a good transform? In the worst case, we'd need 4 instructions in place of the select: xor, zext, insertelement, shufflevector.

http://reviews.llvm.org/D21899

Files:
  lib/Transforms/InstCombine/InstCombineSelect.cpp
  test/Transforms/InstCombine/apint-select.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21899.62377.patch
Type: text/x-patch
Size: 5534 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160630/15b478c9/attachment.bin>


More information about the llvm-commits mailing list