1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 19:12:56 +02:00
llvm-mirror/lib/Transforms/InstCombine
Sanjay Patel 500fe712ac [InstCombine] look through bitcasts to find selects
There was concern that creating bitcasts for the simpler potential select pattern:

define <2 x i64> @vecBitcastOp1(<4 x i1> %cmp, <2 x i64> %a) {
  %a2 = add <2 x i64> %a, %a
  %sext = sext <4 x i1> %cmp to <4 x i32>
  %bc = bitcast <4 x i32> %sext to <2 x i64>
  %and = and <2 x i64> %a2, %bc
  ret <2 x i64> %and
}

might lead to worse code for some targets, so this patch is matching the larger
patterns seen in the test cases.

The motivating example for this patch is this IR produced via SSE intrinsics in C:

define <2 x i64> @gibson(<2 x i64> %a, <2 x i64> %b) {
  %t0 = bitcast <2 x i64> %a to <4 x i32>
  %t1 = bitcast <2 x i64> %b to <4 x i32>
  %cmp = icmp sgt <4 x i32> %t0, %t1
  %sext = sext <4 x i1> %cmp to <4 x i32>
  %t2 = bitcast <4 x i32> %sext to <2 x i64>
  %and = and <2 x i64> %t2, %a
  %neg = xor <4 x i32> %sext, <i32 -1, i32 -1, i32 -1, i32 -1>
  %neg2 = bitcast <4 x i32> %neg to <2 x i64>
  %and2 = and <2 x i64> %neg2, %b
  %or = or <2 x i64> %and, %and2
  ret <2 x i64> %or
}

For an AVX target, this is currently:

vpcmpgtd  %xmm1, %xmm0, %xmm2
vpand     %xmm0, %xmm2, %xmm0
vpandn    %xmm1, %xmm2, %xmm1
vpor      %xmm1, %xmm0, %xmm0
retq

With this patch, it becomes:

vpmaxsd   %xmm1, %xmm0, %xmm0

Differential Revision: http://reviews.llvm.org/D20774

llvm-svn: 271676
2016-06-03 14:42:07 +00:00
..
CMakeLists.txt Use ADDITIONAL_HEADER_DIRS in all LLVM CMake projects. 2015-02-11 03:28:02 +00:00
InstCombineAddSub.cpp Remove uses of builtin comma operator. 2016-02-18 22:09:30 +00:00
InstCombineAndOrXor.cpp [InstCombine] look through bitcasts to find selects 2016-06-03 14:42:07 +00:00
InstCombineCalls.cpp [X86] Remove SSE/AVX unaligned store intrinsics as clang no longer uses them. Auto upgrade to native unaligned store instructions. 2016-05-30 23:15:56 +00:00
InstCombineCasts.cpp [InstCombine] Fix assertion when bitcast is converted to gep 2016-05-23 19:23:17 +00:00
InstCombineCompares.cpp [InstCombine] add another test for wrong icmp constant (PR27792) 2016-05-17 20:20:40 +00:00
InstCombineInternal.h Clarify that we match BSwap in InstCombine and BitReverse in CGP. NFC. 2016-05-25 16:22:14 +00:00
InstCombineLoadStoreAlloca.cpp Reapply 267210 with fix for PR27490 2016-05-06 22:17:01 +00:00
InstCombineMulDivRem.cpp reduce indent; NFC 2016-05-22 17:08:52 +00:00
InstCombinePHI.cpp [InstCombine] Preserve fast math flags when combining PHIs 2016-04-22 11:21:36 +00:00
InstCombineSelect.cpp [InstCombine] Determine the result of a select based on a dominating condition. 2016-04-29 21:12:31 +00:00
InstCombineShifts.cpp add FIXME comment; NFC 2016-04-11 17:35:57 +00:00
InstCombineSimplifyDemanded.cpp [InstCombine] clean up; NFC 2016-04-29 20:54:56 +00:00
InstCombineVectorOps.cpp Fix an issue where fast math flags were dropped during scalarization. 2016-03-01 19:35:52 +00:00
InstructionCombining.cpp X86: permit using SjLj EH on x86 targets as an option 2016-05-31 01:48:07 +00:00
LLVMBuild.txt Update libdeps since TLI was moved from Target to Analysis in r226078. 2015-01-15 05:21:00 +00:00