mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-02-28 22:37:18 +00:00
Add LICM test cases
These test cases check whether Polly still gives the same results if LICM runs before. Currently, it does not and therefore these cases are expected fails. llvm-svn: 243037
This commit is contained in:
parent
75b6b0c5bd
commit
5e9f249c3e
49
polly/test/ScopInfo/licm_load.ll
Normal file
49
polly/test/ScopInfo/licm_load.ll
Normal file
@ -0,0 +1,49 @@
|
||||
; RUN: opt %loadPolly -basicaa -loop-rotate -indvars -polly-prepare -polly-scops -analyze < %s | FileCheck %s
|
||||
; RUN: opt %loadPolly -basicaa -loop-rotate -indvars -licm -polly-prepare -polly-scops -analyze < %s | FileCheck %s
|
||||
;
|
||||
; XFAIL: *
|
||||
;
|
||||
; void foo(int n, float A[static const restrict n],
|
||||
; float B[static const restrict n], int j) {
|
||||
; for (int i = 0; i < n; i++)
|
||||
; A[i] = B[j];
|
||||
; }
|
||||
;
|
||||
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
|
||||
|
||||
define void @foo(i32 %n, float* noalias nonnull %A, float* noalias nonnull %B, i32 %j) {
|
||||
entry:
|
||||
%tmp = sext i32 %n to i64
|
||||
br label %for.cond
|
||||
|
||||
for.cond: ; preds = %for.inc, %entry
|
||||
%indvars.iv = phi i64 [ %indvars.iv.next, %for.inc ], [ 0, %entry ]
|
||||
%cmp = icmp slt i64 %indvars.iv, %tmp
|
||||
br i1 %cmp, label %for.body, label %for.end
|
||||
|
||||
for.body: ; preds = %for.cond
|
||||
%idxprom = sext i32 %j to i64
|
||||
%arrayidx = getelementptr inbounds float, float* %B, i64 %idxprom
|
||||
%tmp1 = bitcast float* %arrayidx to i32*
|
||||
%tmp2 = load i32, i32* %tmp1, align 4
|
||||
%arrayidx2 = getelementptr inbounds float, float* %A, i64 %indvars.iv
|
||||
%tmp3 = bitcast float* %arrayidx2 to i32*
|
||||
store i32 %tmp2, i32* %tmp3, align 4
|
||||
br label %for.inc
|
||||
|
||||
for.inc: ; preds = %for.body
|
||||
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
|
||||
br label %for.cond
|
||||
|
||||
for.end: ; preds = %for.cond
|
||||
ret void
|
||||
}
|
||||
|
||||
|
||||
; CHECK: Statements {
|
||||
; CHECK: Stmt_for_body
|
||||
; CHECK-DAG: ReadAccess := [Reduction Type: NONE] [Scalar: 0]
|
||||
; CHECK-NEXT: [n, j] -> { Stmt_for_body[i0] -> MemRef_B[j] };
|
||||
; CHECK=DAG: MustWriteAccess := [Reduction Type: NONE] [Scalar: 0]
|
||||
; CHECK-NEXT: [n, j] -> { Stmt_for_body[i0] -> MemRef_A[i0] };
|
||||
; CHECK: }
|
81
polly/test/ScopInfo/licm_potential_store.ll
Normal file
81
polly/test/ScopInfo/licm_potential_store.ll
Normal file
@ -0,0 +1,81 @@
|
||||
; RUN: opt %loadPolly -basicaa -sroa -instcombine -simplifycfg -tailcallopt -simplifycfg -reassociate -loop-rotate -instcombine -indvars -polly-prepare -print-function -polly-scops -analyze < %s | FileCheck %s
|
||||
; RUN: opt %loadPolly -basicaa -sroa -instcombine -simplifycfg -tailcallopt -simplifycfg -reassociate -loop-rotate -instcombine -indvars -licm -polly-prepare -print-function -polly-scops -analyze < %s | FileCheck %s
|
||||
;
|
||||
; XFAIL: *
|
||||
;
|
||||
; This one doesn't even detext scops without LICM. Interestingly clang with
|
||||
; --polly-position=early does.
|
||||
;
|
||||
; void foo(int n, float A[static const restrict n], float x) {
|
||||
; // (0)
|
||||
; for (int i = 0; i < 5; i += 1) {
|
||||
; for (int j = 0; j < n; j += 1) {
|
||||
; x = 7; // (1)
|
||||
; }
|
||||
; A[0] = x; // (3)
|
||||
; }
|
||||
; // (4)
|
||||
; }
|
||||
;
|
||||
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
|
||||
|
||||
define void @foo(i32 %n, float* noalias nonnull %A, float %x) {
|
||||
entry:
|
||||
%n.addr = alloca i32, align 4
|
||||
%A.addr = alloca float*, align 8
|
||||
%x.addr = alloca float, align 4
|
||||
%i = alloca i32, align 4
|
||||
%j = alloca i32, align 4
|
||||
store i32 %n, i32* %n.addr, align 4
|
||||
store float* %A, float** %A.addr, align 8
|
||||
store float %x, float* %x.addr, align 4
|
||||
%tmp = load i32, i32* %n.addr, align 4
|
||||
%tmp1 = zext i32 %tmp to i64
|
||||
store i32 0, i32* %i, align 4
|
||||
br label %for.cond
|
||||
|
||||
for.cond: ; preds = %for.inc.4, %entry
|
||||
%tmp2 = load i32, i32* %i, align 4
|
||||
%cmp = icmp slt i32 %tmp2, 5
|
||||
br i1 %cmp, label %for.body, label %for.end.6
|
||||
|
||||
for.body: ; preds = %for.cond
|
||||
store i32 0, i32* %j, align 4
|
||||
br label %for.cond.1
|
||||
|
||||
for.cond.1: ; preds = %for.inc, %for.body
|
||||
%tmp3 = load i32, i32* %j, align 4
|
||||
%tmp4 = load i32, i32* %n.addr, align 4
|
||||
%cmp2 = icmp slt i32 %tmp3, %tmp4
|
||||
br i1 %cmp2, label %for.body.3, label %for.end
|
||||
|
||||
for.body.3: ; preds = %for.cond.1
|
||||
store float 7.000000e+00, float* %x.addr, align 4
|
||||
br label %for.inc
|
||||
|
||||
for.inc: ; preds = %for.body.3
|
||||
%tmp5 = load i32, i32* %j, align 4
|
||||
%add = add nsw i32 %tmp5, 1
|
||||
store i32 %add, i32* %j, align 4
|
||||
br label %for.cond.1
|
||||
|
||||
for.end: ; preds = %for.cond.1
|
||||
%tmp6 = load float, float* %x.addr, align 4
|
||||
%tmp7 = load float*, float** %A.addr, align 8
|
||||
%arrayidx = getelementptr inbounds float, float* %tmp7, i64 0
|
||||
store float %tmp6, float* %arrayidx, align 4
|
||||
br label %for.inc.4
|
||||
|
||||
for.inc.4: ; preds = %for.end
|
||||
%tmp8 = load i32, i32* %i, align 4
|
||||
%add5 = add nsw i32 %tmp8, 1
|
||||
store i32 %add5, i32* %i, align 4
|
||||
br label %for.cond
|
||||
|
||||
for.end.6: ; preds = %for.cond
|
||||
ret void
|
||||
}
|
||||
|
||||
; CHECK: Statements {
|
||||
; CHECK: Stmt_for_end
|
||||
; CHECK: }
|
47
polly/test/ScopInfo/licm_reduction.ll
Normal file
47
polly/test/ScopInfo/licm_reduction.ll
Normal file
@ -0,0 +1,47 @@
|
||||
; RUN: opt %loadPolly -basicaa -loop-rotate -indvars -polly-prepare -polly-scops -analyze < %s | FileCheck %s
|
||||
; RUN: opt %loadPolly -basicaa -loop-rotate -indvars -licm -polly-prepare -polly-scops -analyze < %s | FileCheck %s
|
||||
;
|
||||
; XFAIL: *
|
||||
;
|
||||
; void test(int n, double B[static const restrict n], int j) {
|
||||
; for (int i = 0; i < n; i += 1) {
|
||||
; B[j] += i;
|
||||
; }
|
||||
; }
|
||||
;
|
||||
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
|
||||
|
||||
define void @test(i32 %n, double* noalias nonnull %B, i32 %j) {
|
||||
entry:
|
||||
br label %for.cond
|
||||
|
||||
for.cond: ; preds = %for.inc, %entry
|
||||
%i.0 = phi i32 [ 0, %entry ], [ %add1, %for.inc ]
|
||||
%cmp = icmp slt i32 %i.0, %n
|
||||
br i1 %cmp, label %for.body, label %for.end
|
||||
|
||||
for.body: ; preds = %for.cond
|
||||
%conv = sitofp i32 %i.0 to double
|
||||
%idxprom = sext i32 %j to i64
|
||||
%arrayidx = getelementptr inbounds double, double* %B, i64 %idxprom
|
||||
%tmp = load double, double* %arrayidx, align 8
|
||||
%add = fadd double %tmp, %conv
|
||||
store double %add, double* %arrayidx, align 8
|
||||
br label %for.inc
|
||||
|
||||
for.inc: ; preds = %for.body
|
||||
%add1 = add nuw nsw i32 %i.0, 1
|
||||
br label %for.cond
|
||||
|
||||
for.end: ; preds = %for.cond
|
||||
ret void
|
||||
}
|
||||
|
||||
|
||||
; CHECK: Statements {
|
||||
; CHECK: Stmt_for_body
|
||||
; CHECK-DAG: ReadAccess := [Reduction Type: NONE] [Scalar: 0]
|
||||
; CHECK-NEXT: [n, j] -> { Stmt_for_body[i0] -> MemRef_B[j] };
|
||||
; CHECK-DAG: MustWriteAccess := [Reduction Type: NONE] [Scalar: 0]
|
||||
; CHECK-NEXT: [n, j] -> { Stmt_for_body[i0] -> MemRef_B[j] };
|
||||
; CHECK: }
|
68
polly/test/ScopInfo/licm_reduction_nested.ll
Normal file
68
polly/test/ScopInfo/licm_reduction_nested.ll
Normal file
@ -0,0 +1,68 @@
|
||||
; RUN: opt %loadPolly -basicaa -loop-rotate -indvars -polly-prepare -polly-scops -analyze < %s | FileCheck %s
|
||||
; RUN: opt %loadPolly -basicaa -loop-rotate -indvars -licm -polly-prepare -polly-scops -analyze < %s | FileCheck %s
|
||||
;
|
||||
; XFAIL: *
|
||||
;
|
||||
; Even ScopDetection fails here after LICM because of PHI in exit node.
|
||||
;
|
||||
; void foo(unsigned long *restrict A, unsigned long *restrict B,
|
||||
; unsigned long j) {
|
||||
; for (unsigned long i = 0; i < 100; i++)
|
||||
; for (unsigned long k = 0; k < 100; k++)
|
||||
; A[j] += B[i + k];
|
||||
; }
|
||||
;
|
||||
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
|
||||
|
||||
define void @foo(i64* noalias %A, i64* noalias %B, i64 %j) {
|
||||
entry:
|
||||
br label %for.cond
|
||||
|
||||
for.cond: ; preds = %for.inc.6, %entry
|
||||
%i.0 = phi i64 [ 0, %entry ], [ %inc7, %for.inc.6 ]
|
||||
%exitcond1 = icmp ne i64 %i.0, 100
|
||||
br i1 %exitcond1, label %for.body, label %for.end.8
|
||||
|
||||
for.body: ; preds = %for.cond
|
||||
br label %for.cond.1
|
||||
|
||||
for.cond.1: ; preds = %for.inc, %for.body
|
||||
%k.0 = phi i64 [ 0, %for.body ], [ %inc, %for.inc ]
|
||||
%exitcond = icmp ne i64 %k.0, 100
|
||||
br i1 %exitcond, label %for.body.3, label %for.end
|
||||
|
||||
for.body.3: ; preds = %for.cond.1
|
||||
%add = add nuw nsw i64 %i.0, %k.0
|
||||
%arrayidx = getelementptr inbounds i64, i64* %B, i64 %add
|
||||
%tmp = load i64, i64* %arrayidx, align 8
|
||||
%arrayidx4 = getelementptr inbounds i64, i64* %A, i64 %j
|
||||
%tmp2 = load i64, i64* %arrayidx4, align 8
|
||||
%add5 = add i64 %tmp2, %tmp
|
||||
store i64 %add5, i64* %arrayidx4, align 8
|
||||
br label %for.inc
|
||||
|
||||
for.inc: ; preds = %for.body.3
|
||||
%inc = add nuw nsw i64 %k.0, 1
|
||||
br label %for.cond.1
|
||||
|
||||
for.end: ; preds = %for.cond.1
|
||||
br label %for.inc.6
|
||||
|
||||
for.inc.6: ; preds = %for.end
|
||||
%inc7 = add nuw nsw i64 %i.0, 1
|
||||
br label %for.cond
|
||||
|
||||
for.end.8: ; preds = %for.cond
|
||||
ret void
|
||||
}
|
||||
|
||||
|
||||
; CHECK: Statements {
|
||||
; CHECK: Stmt_for_body_3
|
||||
; CHECK-DAG: ReadAccess := [Reduction Type: NONE] [Scalar: 0]
|
||||
; CHECK-NEXT: [j] -> { Stmt_for_body_3[i0, i1] -> MemRef_B[i0 + i1] };
|
||||
; CHECK-DAG: ReadAccess := [Reduction Type: +] [Scalar: 0]
|
||||
; CHECK-NEXT: [j] -> { Stmt_for_body_3[i0, i1] -> MemRef_A[j] };
|
||||
; CHECK-DAG: MustWriteAccess := [Reduction Type: +] [Scalar: 0]
|
||||
; CHECK-NEXT: [j] -> { Stmt_for_body_3[i0, i1] -> MemRef_A[j] };
|
||||
; CHECK: }
|
45
polly/test/ScopInfo/licm_store.ll
Normal file
45
polly/test/ScopInfo/licm_store.ll
Normal file
@ -0,0 +1,45 @@
|
||||
; RUN: opt %loadPolly -basicaa -loop-rotate -indvars -polly-prepare -polly-scops -analyze < %s | FileCheck %s
|
||||
; RUN: opt %loadPolly -basicaa -loop-rotate -indvars -licm -polly-prepare -polly-scops -analyze < %s | FileCheck %s
|
||||
;
|
||||
; XFAIL: *
|
||||
;
|
||||
; void foo(float *restrict A, float *restrict B, long j) {
|
||||
; for (long i = 0; i < 100; i++)
|
||||
; A[j] = B[i];
|
||||
; }
|
||||
;
|
||||
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
|
||||
|
||||
define void @foo(float* noalias %A, float* noalias %B, i64 %j) {
|
||||
entry:
|
||||
br label %for.cond
|
||||
|
||||
for.cond: ; preds = %for.inc, %entry
|
||||
%i.0 = phi i64 [ 0, %entry ], [ %inc, %for.inc ]
|
||||
%exitcond = icmp ne i64 %i.0, 100
|
||||
br i1 %exitcond, label %for.body, label %for.end
|
||||
|
||||
for.body: ; preds = %for.cond
|
||||
%arrayidx = getelementptr inbounds float, float* %B, i64 %i.0
|
||||
%tmp = bitcast float* %arrayidx to i32*
|
||||
%tmp1 = load i32, i32* %tmp, align 4
|
||||
%arrayidx1 = getelementptr inbounds float, float* %A, i64 %j
|
||||
%tmp2 = bitcast float* %arrayidx1 to i32*
|
||||
store i32 %tmp1, i32* %tmp2, align 4
|
||||
br label %for.inc
|
||||
|
||||
for.inc: ; preds = %for.body
|
||||
%inc = add nuw nsw i64 %i.0, 1
|
||||
br label %for.cond
|
||||
|
||||
for.end: ; preds = %for.cond
|
||||
ret void
|
||||
}
|
||||
|
||||
; CHECK: Statements {
|
||||
; CHECK: Stmt_for_body
|
||||
; CHECK-DAG: ReadAccess := [Reduction Type: NONE] [Scalar: 0]
|
||||
; CHECK-NEXT: [j] -> { Stmt_for_body[i0] -> MemRef_B[i0] };
|
||||
; CHECK-DAG: MustWriteAccess := [Reduction Type: NONE] [Scalar: 0]
|
||||
; CHECK-NEXT: [j] -> { Stmt_for_body[i0] -> MemRef_A[j] };
|
||||
; CHECK: }
|
Loading…
x
Reference in New Issue
Block a user