[Hexagon] Adding a number of other tests for min/max instructions and loading i1s.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@239935 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Colin LeMahieu 2015-06-17 20:29:33 +00:00
parent a1e31b45cc
commit 6fc90b32e3
19 changed files with 327 additions and 2 deletions

View File

@ -0,0 +1,16 @@
; RUN: llc -march=hexagon < %s | FileCheck %s
; CHECK: memub(r{{[0-9]+}}{{ *}}<<{{ *}}#1{{ *}}+{{ *}}##a)
@a = external global [5 x [2 x i8]]
define zeroext i8 @foo(i8 zeroext %l) nounwind readonly {
for.end:
%idxprom = zext i8 %l to i32
%arrayidx1 = getelementptr inbounds [5 x [2 x i8]], [5 x [2 x i8]]* @a, i32 0, i32 %idxprom, i32 0
%0 = load i8, i8* %arrayidx1, align 1
%conv = zext i8 %0 to i32
%mul = mul nsw i32 %conv, 20
%conv2 = trunc i32 %mul to i8
ret i8 %conv2
}

View File

@ -0,0 +1,16 @@
; RUN: llc -march=hexagon < %s | FileCheck %s
; CHECK: memuh(r{{[0-9]+}}{{ *}}<<{{ *}}#2{{ *}}+{{ *}}##a)
@a = external global [5 x [2 x i16]]
define signext i16 @foo(i16 zeroext %l) nounwind readonly {
for.end:
%idxprom = zext i16 %l to i32
%arrayidx1 = getelementptr inbounds [5 x [2 x i16]], [5 x [2 x i16]]* @a, i32 0, i32 %idxprom, i32 0
%0 = load i16, i16* %arrayidx1, align 2
%conv = zext i16 %0 to i32
%mul = mul nsw i32 %conv, 20
%conv2 = trunc i32 %mul to i16
ret i16 %conv2
}

View File

@ -1,4 +1,4 @@
; RUN: llc -march=hexagon -mcpu=hexagonv4 -O3 < %s | FileCheck %s ; RUN: llc -march=hexagon -O3 < %s | FileCheck %s
; CHECK-LABEL: @test_pos1_ir_slt ; CHECK-LABEL: @test_pos1_ir_slt
; CHECK: loop0 ; CHECK: loop0

View File

@ -1,4 +1,4 @@
; RUN: llc -march=hexagon -mcpu=hexagonv4 < %s | FileCheck %s ; RUN: llc -march=hexagon < %s | FileCheck %s
; Check that we generate a hardware loop instruction. ; Check that we generate a hardware loop instruction.
; CHECK: endloop0 ; CHECK: endloop0

View File

@ -0,0 +1,43 @@
; RUN: llc -march=hexagon -mcpu=hexagonv5 -hexagon-small-data-threshold=0 < %s | FileCheck %s
target datalayout = "e-p:32:32:32-i64:64:64-i32:32:32-i16:16:16-i1:32:32-f64:64:64-f32:32:32-a0:0-n32"
target triple = "hexagon-unknown-linux-gnu"
@flag = external global i1
; CHECK-NOT: CONST
define i32 @test_sextloadi1_32() {
entry:
%0 = load i1, i1* @flag, align 4
%1 = sext i1 %0 to i32
ret i32 %1
}
define i16 @test_zextloadi1_16() {
entry:
%0 = load i1, i1* @flag, align 4
%1 = zext i1 %0 to i16
ret i16 %1
}
define i32 @test_zextloadi1_32() {
entry:
%0 = load i1, i1* @flag, align 4
%1 = zext i1 %0 to i32
ret i32 %1
}
define i64 @test_zextloadi1_64() {
entry:
%0 = load i1, i1* @flag, align 4
%1 = zext i1 %0 to i64
ret i64 %1
}

View File

@ -0,0 +1,43 @@
; RUN: llc -march=hexagon -hexagon-small-data-threshold=0 < %s | FileCheck %s
target datalayout = "e-p:32:32:32-i64:64:64-i32:32:32-i16:16:16-i1:32:32-f64:64:64-f32:32:32-a0:0-n32"
target triple = "hexagon-unknown-linux-gnu"
@flag = external global i1
; CHECK-NOT: CONST
define i32 @test_sextloadi1_32() {
entry:
%0 = load i1, i1* @flag, align 4
%1 = sext i1 %0 to i32
ret i32 %1
}
define i16 @test_zextloadi1_16() {
entry:
%0 = load i1, i1* @flag, align 4
%1 = zext i1 %0 to i16
ret i16 %1
}
define i32 @test_zextloadi1_32() {
entry:
%0 = load i1, i1* @flag, align 4
%1 = zext i1 %0 to i32
ret i32 %1
}
define i64 @test_zextloadi1_64() {
entry:
%0 = load i1, i1* @flag, align 4
%1 = zext i1 %0 to i64
ret i64 %1
}

View File

@ -0,0 +1,45 @@
; RUN: llc -march=hexagon < %s | FileCheck %s
target datalayout = "e-p:32:32:32-i64:64:64-i32:32:32-i16:16:16-i1:32:32-f64:64:64-f32:32:32-a0:0-n32"
target triple = "hexagon-unknown-linux-gnu"
@flag = external global i1
define i32 @test_sextloadi1_32() {
entry:
%0 = load i1, i1* @flag, align 4
; CHECK: memub
%1 = sext i1 %0 to i32
ret i32 %1
}
define i16 @test_zextloadi1_16() {
entry:
%0 = load i1, i1* @flag, align 4
; CHECK: memub
%1 = zext i1 %0 to i16
ret i16 %1
}
define i32 @test_zextloadi1_32() {
entry:
%0 = load i1, i1* @flag, align 4
; CHECK: memub
%1 = zext i1 %0 to i32
ret i32 %1
}
define i64 @test_zextloadi1_64() {
entry:
%0 = load i1, i1* @flag, align 4
; CHECK: memub
%1 = zext i1 %0 to i64
ret i64 %1
}

View File

@ -0,0 +1,45 @@
; RUN: llc -march=hexagon -mcpu=hexagonv5 < %s | FileCheck %s
target datalayout = "e-p:32:32:32-i64:64:64-i32:32:32-i16:16:16-i1:32:32-f64:64:64-f32:32:32-a0:0-n32"
target triple = "hexagon-unknown-linux-gnu"
@flag = external global i1
define i32 @test_sextloadi1_32() {
entry:
%0 = load i1, i1* @flag, align 4
; CHECK: memub
%1 = sext i1 %0 to i32
ret i32 %1
}
define i16 @test_zextloadi1_16() {
entry:
%0 = load i1, i1* @flag, align 4
; CHECK: memub
%1 = zext i1 %0 to i16
ret i16 %1
}
define i32 @test_zextloadi1_32() {
entry:
%0 = load i1, i1* @flag, align 4
; CHECK: memub
%1 = zext i1 %0 to i32
ret i32 %1
}
define i64 @test_zextloadi1_64() {
entry:
%0 = load i1, i1* @flag, align 4
; CHECK: memub
%1 = zext i1 %0 to i64
ret i64 %1
}

View File

@ -0,0 +1,9 @@
; RUN: llc -march=hexagon < %s | FileCheck %s
; CHECK: max
define i64 @f(i64 %src, i64 %maxval) nounwind readnone {
entry:
%cmp = icmp slt i64 %maxval, %src
%cond = select i1 %cmp, i64 %src, i64 %maxval
ret i64 %cond
}

View File

@ -0,0 +1,23 @@
; RUN: llc -march=hexagon < %s | FileCheck %s
; The result of max(half-word, half-word) is also half-word.
; Check that we are not producing a sign extend after the max.
; CHECK-NOT: sxth
define i64 @test_cast(i64 %arg0, i16 zeroext %arg1, i16 zeroext %arg2) nounwind readnone {
entry:
%conv.i = zext i16 %arg1 to i32
%conv1.i = zext i16 %arg2 to i32
%sub.i = sub nsw i32 %conv.i, %conv1.i
%sext.i = shl i32 %sub.i, 16
%cmp.i = icmp slt i32 %sext.i, 65536
%0 = ashr exact i32 %sext.i, 16
%conv7.i = select i1 %cmp.i, i32 1, i32 %0
%cmp8.i = icmp sgt i32 %conv7.i, 4
%conv7.op.i = add i32 %conv7.i, 65535
%shl = shl i64 %arg0, 2
%.mask = and i32 %conv7.op.i, 65535
%1 = zext i32 %.mask to i64
%conv = select i1 %cmp8.i, i64 3, i64 %1
%or = or i64 %conv, %shl
ret i64 %or
}

View File

@ -0,0 +1,9 @@
; RUN: llc -march=hexagon < %s | FileCheck %s
; CHECK: maxu
define i64 @f(i64 %src, i64 %maxval) nounwind readnone {
entry:
%cmp = icmp ult i64 %maxval, %src
%cond = select i1 %cmp, i64 %src, i64 %maxval
ret i64 %cond
}

View File

@ -0,0 +1,9 @@
; RUN: llc -march=hexagon < %s | FileCheck %s
; CHECK: maxu
define i32 @f(i32 %src, i32 %maxval) nounwind readnone {
entry:
%cmp = icmp ult i32 %maxval, %src
%cond = select i1 %cmp, i32 %src, i32 %maxval
ret i32 %cond
}

View File

@ -0,0 +1,9 @@
; RUN: llc -march=hexagon < %s | FileCheck %s
; CHECK: max
define i32 @f(i32 %src, i32 %maxval) nounwind readnone {
entry:
%cmp = icmp slt i32 %maxval, %src
%cond = select i1 %cmp, i32 %src, i32 %maxval
ret i32 %cond
}

View File

@ -0,0 +1,9 @@
; RUN: llc -march=hexagon < %s | FileCheck %s
; CHECK: min
define i64 @f(i64 %src, i64 %maxval) nounwind readnone {
entry:
%cmp = icmp sgt i64 %maxval, %src
%cond = select i1 %cmp, i64 %src, i64 %maxval
ret i64 %cond
}

View File

@ -0,0 +1,11 @@
; RUN: llc -march=hexagon < %s | FileCheck %s
; CHECK: minu
define zeroext i16 @f(i16* noalias nocapture %src) nounwind readonly {
entry:
%arrayidx = getelementptr inbounds i16, i16* %src, i32 1
%0 = load i16, i16* %arrayidx, align 1
%cmp = icmp ult i16 %0, 32767
%. = select i1 %cmp, i16 %0, i16 32767
ret i16 %.
}

View File

@ -0,0 +1,11 @@
; RUN: llc -march=hexagon < %s | FileCheck %s
; CHECK: minu
define zeroext i8 @f(i8* noalias nocapture %src) nounwind readonly {
entry:
%arrayidx = getelementptr inbounds i8, i8* %src, i32 1
%0 = load i8, i8* %arrayidx, align 1
%cmp = icmp ult i8 %0, 127
%. = select i1 %cmp, i8 %0, i8 127
ret i8 %.
}

View File

@ -0,0 +1,9 @@
; RUN: llc -march=hexagon < %s | FileCheck %s
; CHECK: minu
define i64 @f(i64 %src, i64 %maxval) nounwind readnone {
entry:
%cmp = icmp ugt i64 %maxval, %src
%cond = select i1 %cmp, i64 %src, i64 %maxval
ret i64 %cond
}

View File

@ -0,0 +1,9 @@
; RUN: llc -march=hexagon < %s | FileCheck %s
; CHECK: minu
define i32 @f(i32 %src, i32 %maxval) nounwind readnone {
entry:
%cmp = icmp ugt i32 %maxval, %src
%cond = select i1 %cmp, i32 %src, i32 %maxval
ret i32 %cond
}

View File

@ -0,0 +1,9 @@
; RUN: llc -march=hexagon < %s | FileCheck %s
; CHECK: min
define i32 @f(i32 %src, i32 %maxval) nounwind readnone {
entry:
%cmp = icmp sgt i32 %maxval, %src
%cond = select i1 %cmp, i32 %src, i32 %maxval
ret i32 %cond
}