Fix Polly
[polly-mirror.git] / unittests / ScheduleOptimizer / ScheduleOptimizerTest.cpp
blobb7fed0b05a1d262df06ccd1e923b2979fe6e3245
1 //===- ScheduleOptimizerTest.cpp ------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "polly/ScheduleOptimizer.h"
10 #include "gtest/gtest.h"
11 #include "isl/stream.h"
12 #include "isl/val.h"
14 using namespace isl;
15 namespace {
17 TEST(ScheduleOptimizer, getPartialTilePrefixes) {
19 isl_ctx *ctx = isl_ctx_alloc();
22 // Verify that for a loop with 3 iterations starting at 0 that is
23 // pre-vectorized (strip-mined with a factor of 2), we correctly identify
24 // that only the first two iterations are full vector iterations.
25 isl::map Schedule(
26 ctx, "{[i] -> [floor(i/2), i - 2 * floor(i/2)] : 0 <= i < 3 }");
27 isl::set ScheduleRange = Schedule.range();
28 isl::set Result = getPartialTilePrefixes(ScheduleRange, 2);
30 EXPECT_TRUE(Result.is_equal(isl::set(ctx, "{[0]}")));
34 // Verify that for a loop with 3 iterations starting at 1 that is
35 // pre-vectorized (strip-mined with a factor of 2), we correctly identify
36 // that only the last two iterations are full vector iterations.
37 isl::map Schedule(
38 ctx, "{[i] -> [floor(i/2), i - 2 * floor(i/2)] : 1 <= i < 4 }");
39 isl::set ScheduleRange = Schedule.range();
40 isl::set Result = getPartialTilePrefixes(ScheduleRange, 2);
42 EXPECT_TRUE(Result.is_equal(isl::set(ctx, "{[1]}")));
46 // Verify that for a loop with 6 iterations starting at 1 that is
47 // pre-vectorized (strip-mined with a factor of 2), we correctly identify
48 // that all but the first and the last iteration are full vector iterations.
49 isl::map Schedule(
50 ctx, "{[i] -> [floor(i/2), i - 2 * floor(i/2)] : 1 <= i < 6 }");
51 isl::set ScheduleRange = Schedule.range();
52 isl::set Result = getPartialTilePrefixes(ScheduleRange, 2);
54 EXPECT_TRUE(Result.is_equal(isl::set(ctx, "{[1]; [2]}")));
57 isl_ctx_free(ctx);
59 } // anonymous namespace