llvm/test/CodeGen/SPARC/vector-extract-elt.ll
Bjorn Pettersson 17676e0feb [DAG] Teach computeKnownBits and ComputeNumSignBits in SelectionDAG to look through EXTRACT_VECTOR_ELT.
Summary: Both computeKnownBits and ComputeNumSignBits can now do a simple
look-through of EXTRACT_VECTOR_ELT. It will compute the result based
on the known bits (or known sign bits) for the vector that the element
is extracted from.

Reviewers: bogner, tstellarAMD, mkuper

Subscribers: wdng, RKSimon, jyknight, llvm-commits, nhaehnle

Differential Revision: https://reviews.llvm.org/D25007

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@283347 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-05 17:40:27 +00:00

20 lines
649 B
LLVM

; RUN: llc -march=sparc < %s | FileCheck %s
; If computeKnownSignBits (in SelectionDAG) can do a simple
; look-thru for extractelement then we we know that the add will yield a
; non-negative result.
define i1 @test1(<4 x i16>* %in) {
; CHECK-LABEL: ! BB#0:
; CHECK-NEXT: retl
; CHECK-NEXT: sethi 0, %o0
%vec2 = load <4 x i16>, <4 x i16>* %in, align 1
%vec3 = lshr <4 x i16> %vec2, <i16 2, i16 2, i16 2, i16 2>
%vec4 = sext <4 x i16> %vec3 to <4 x i32>
%elt0 = extractelement <4 x i32> %vec4, i32 0
%elt1 = extractelement <4 x i32> %vec4, i32 1
%sum = add i32 %elt0, %elt1
%bool = icmp slt i32 %sum, 0
ret i1 %bool
}