1 //===- ScheduleOptimizerTest.cpp ------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 #include "polly/ScheduleOptimizer.h"
10 #include "gtest/gtest.h"
11 #include "isl/stream.h"
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.
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.
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.
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]}")));
59 } // anonymous namespace