1 //===- ScheduleOptimizerTest.cpp ------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "polly/ScheduleOptimizer.h"
11 #include "gtest/gtest.h"
12 #include "isl/stream.h"
18 TEST(ScheduleOptimizer
, getPartialTilePrefixes
) {
20 isl_ctx
*ctx
= isl_ctx_alloc();
23 // Verify that for a loop with 3 iterations starting at 0 that is
24 // pre-vectorized (strip-mined with a factor of 2), we correctly identify
25 // that only the first two iterations are full vector iterations.
27 ctx
, "{[i] -> [floor(i/2), i - 2 * floor(i/2)] : 0 <= i < 3 }");
28 isl::set ScheduleRange
= Schedule
.range();
29 isl::set Result
= getPartialTilePrefixes(ScheduleRange
, 2);
31 EXPECT_TRUE(Result
.is_equal(isl::set(ctx
, "{[0]}")));
35 // Verify that for a loop with 3 iterations starting at 1 that is
36 // pre-vectorized (strip-mined with a factor of 2), we correctly identify
37 // that only the last two iterations are full vector iterations.
39 ctx
, "{[i] -> [floor(i/2), i - 2 * floor(i/2)] : 1 <= i < 4 }");
40 isl::set ScheduleRange
= Schedule
.range();
41 isl::set Result
= getPartialTilePrefixes(ScheduleRange
, 2);
43 EXPECT_TRUE(Result
.is_equal(isl::set(ctx
, "{[1]}")));
47 // Verify that for a loop with 6 iterations starting at 1 that is
48 // pre-vectorized (strip-mined with a factor of 2), we correctly identify
49 // that all but the first and the last iteration are full vector iterations.
51 ctx
, "{[i] -> [floor(i/2), i - 2 * floor(i/2)] : 1 <= i < 6 }");
52 isl::set ScheduleRange
= Schedule
.range();
53 isl::set Result
= getPartialTilePrefixes(ScheduleRange
, 2);
55 EXPECT_TRUE(Result
.is_equal(isl::set(ctx
, "{[1]; [2]}")));
60 } // anonymous namespace