From 235726ee4b868e665d64d41c1a24f9c061845d9c Mon Sep 17 00:00:00 2001 From: Michael Kruse Date: Tue, 8 Aug 2017 17:26:19 +0000 Subject: [PATCH] [test] Add descriptions and pseudocode to tests. NFC. llvm-svn: 310385 --- polly/test/ForwardOpTree/forward_hoisted.ll | 3 ++- polly/test/ForwardOpTree/forward_load.ll | 8 ++++++++ .../forward_load_differentarray.ll | 15 +++++++++++++++ .../test/ForwardOpTree/forward_load_fromloop.ll | 14 ++++++++++++++ .../test/ForwardOpTree/forward_load_indirect.ll | 12 ++++++++++++ .../ForwardOpTree/forward_load_tripleuse.ll | 17 +++++++++++++++++ .../ForwardOpTree/noforward_load_conditional.ll | 15 +++++++++++++++ .../noforward_load_writebetween.ll | 11 +++++++++++ 8 files changed, 94 insertions(+), 1 deletion(-) diff --git a/polly/test/ForwardOpTree/forward_hoisted.ll b/polly/test/ForwardOpTree/forward_hoisted.ll index 7efaf2b5ec0c..3241f07de6b4 100644 --- a/polly/test/ForwardOpTree/forward_hoisted.ll +++ b/polly/test/ForwardOpTree/forward_hoisted.ll @@ -1,6 +1,7 @@ ; RUN: opt %loadPolly -polly-invariant-load-hoisting=true -polly-optree -analyze < %s | FileCheck %s -match-full-lines ; -; Move %val to %bodyB, so %bodyA can be removed (by -polly-simplify) +; Move %val to %bodyB, so %bodyA can be removed (by -polly-simplify). +; This involves making the load-hoisted %val1 to be made available in %bodyB. ; ; for (int j = 0; j < n; j += 1) { ; bodyA: diff --git a/polly/test/ForwardOpTree/forward_load.ll b/polly/test/ForwardOpTree/forward_load.ll index 176ea97e8279..9281f199f60c 100644 --- a/polly/test/ForwardOpTree/forward_load.ll +++ b/polly/test/ForwardOpTree/forward_load.ll @@ -2,6 +2,14 @@ ; ; Rematerialize a load. ; +; for (int j = 0; j < n; j += 1) { +; bodyA: +; double val = B[j]; +; +; bodyB: +; A[j] = val; +; } +; define void @func(i32 %n, double* noalias nonnull %A, double* noalias nonnull %B) { entry: br label %for diff --git a/polly/test/ForwardOpTree/forward_load_differentarray.ll b/polly/test/ForwardOpTree/forward_load_differentarray.ll index 7580ddbd0c8d..26342820044a 100644 --- a/polly/test/ForwardOpTree/forward_load_differentarray.ll +++ b/polly/test/ForwardOpTree/forward_load_differentarray.ll @@ -1,5 +1,20 @@ ; RUN: opt %loadPolly -polly-optree -analyze < %s | FileCheck %s -match-full-lines ; +; To forward %val, B[j] cannot be reused in bodyC because it is overwritten +; between. Verify that instead the alternative C[j] is used. +; +; for (int j = 0; j < n; j += 1) { +; bodyA: +; double val = B[j]; +; +; bodyB: +; B[j] = 0; +; C[j] = val; +; +; bodyC: +; A[j] = val; +; } +; define void @func(i32 %n, double* noalias nonnull %A, double* noalias nonnull %B, double* noalias nonnull %C) { entry: br label %for diff --git a/polly/test/ForwardOpTree/forward_load_fromloop.ll b/polly/test/ForwardOpTree/forward_load_fromloop.ll index ef24924fd372..511df9869493 100644 --- a/polly/test/ForwardOpTree/forward_load_fromloop.ll +++ b/polly/test/ForwardOpTree/forward_load_fromloop.ll @@ -1,5 +1,19 @@ ; RUN: opt %loadPolly -polly-optree -analyze < %s | FileCheck %s -match-full-lines ; +; Forward a the LoadInst %val into %bodyB. %val is executed multiple times, +; we must get the last loaded values. +; +; for (int j = 0; j < n; j += 1) { +; double val; +; for (int i = 0; i < n; i += 1) { +; bodyA: +; val = B[j]; +; } +; +; bodyB: +; A[j] = val; +; } +; define void @func(i32 %n, double* noalias nonnull %A, double* noalias nonnull %B) { entry: br label %for diff --git a/polly/test/ForwardOpTree/forward_load_indirect.ll b/polly/test/ForwardOpTree/forward_load_indirect.ll index 58ef66758d9e..243ee2f7499f 100644 --- a/polly/test/ForwardOpTree/forward_load_indirect.ll +++ b/polly/test/ForwardOpTree/forward_load_indirect.ll @@ -1,5 +1,17 @@ ; RUN: opt %loadPolly -polly-optree -analyze < %s | FileCheck %s -match-full-lines ; +; Forward an operand tree consisting of a speculatable instruction (%add) +; and a load (%val). +; +; for (int j = 0; j < n; j += 1) { +; bodyA: +; double val = B[j]; +; double add = val + 42.0; +; +; bodyB: +; A[j] = add; +; } +; define void @func(i32 %n, double* noalias nonnull %A, double* noalias nonnull %B) { entry: br label %for diff --git a/polly/test/ForwardOpTree/forward_load_tripleuse.ll b/polly/test/ForwardOpTree/forward_load_tripleuse.ll index 2d4f789b6918..c1528281bfcb 100644 --- a/polly/test/ForwardOpTree/forward_load_tripleuse.ll +++ b/polly/test/ForwardOpTree/forward_load_tripleuse.ll @@ -1,5 +1,22 @@ ; RUN: opt %loadPolly -polly-optree -polly-codegen -analyze < %s | FileCheck %s -match-full-lines ; +; %val1 is used three times: Twice by its own operand tree of %val2 and once +; more by the store in %bodyB. +; Verify that we can handle multiple uses by the same instruction and uses +; in multiple statements as well. +; The result processing may depend on the order in which the values are used, +; hence we check both orderings. +; +; for (int j = 0; j < n; j += 1) { +; bodyA: +; double val1 = A[j]; +; double val2 = val1 + val1; +; +; bodyB: +; B[j] = val1; +; C[j] = val2; +; } +; define void @func1(i32 %n, double* noalias nonnull %A, double* noalias nonnull %B, double* noalias nonnull %C) { entry: br label %for diff --git a/polly/test/ForwardOpTree/noforward_load_conditional.ll b/polly/test/ForwardOpTree/noforward_load_conditional.ll index a4b31d1847cd..95bec95ecd07 100644 --- a/polly/test/ForwardOpTree/noforward_load_conditional.ll +++ b/polly/test/ForwardOpTree/noforward_load_conditional.ll @@ -1,5 +1,20 @@ ; RUN: opt %loadPolly -polly-optree -analyze < %s | FileCheck %s -match-full-lines ; +; B[j] is overwritten by at least one statement between the +; definition of %val and its use. Hence, it cannot be forwarded. +; +; for (int j = 0; j < n; j += 1) { +; bodyA: +; double val = B[j]; +; if (j < 1) { +; bodyA_true: +; B[j] = 0.0; +; } +; +; bodyB: +; A[j] = val; +; } +; define void @func(i32 %n, double* noalias nonnull %A, double* noalias nonnull %B) { entry: br label %for diff --git a/polly/test/ForwardOpTree/noforward_load_writebetween.ll b/polly/test/ForwardOpTree/noforward_load_writebetween.ll index f4fc701fd82f..3c84d5f96b71 100644 --- a/polly/test/ForwardOpTree/noforward_load_writebetween.ll +++ b/polly/test/ForwardOpTree/noforward_load_writebetween.ll @@ -3,6 +3,17 @@ ; Cannot rematerialize %val from B[0] at bodyC because B[0] has been ; overwritten in bodyB. ; +; for (int j = 0; j < n; j += 1) { +; bodyA: +; double val = B[j]; +; +; bodyB: +; B[j] = 0.0; +; +; bodyC: +; A[j] = val; +; } +; define void @func(i32 %n, double* noalias nonnull %A, double* noalias nonnull %B) { entry: br label %for