1 //===- ScheduleTreeTransformTest.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 //===----------------------------------------------------------------------===// 8 9 #include "polly/ScheduleTreeTransform.h" 10 #include "gtest/gtest.h" 11 #include "isl/ctx.h" 12 13 using namespace isl; 14 using namespace polly; 15 16 namespace { 17 18 TEST(ScheduleTreeTransform, getPartialTilePrefixes) { 19 isl_ctx *ctx = isl_ctx_alloc(); 20 21 { 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); 29 30 EXPECT_TRUE(Result.is_equal(isl::set(ctx, "{[0]}"))); 31 } 32 33 { 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); 41 42 EXPECT_TRUE(Result.is_equal(isl::set(ctx, "{[1]}"))); 43 } 44 45 { 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); 53 54 EXPECT_TRUE(Result.is_equal(isl::set(ctx, "{[1]; [2]}"))); 55 } 56 57 isl_ctx_free(ctx); 58 } 59 } // anonymous namespace 60