================
@@ -0,0 +1,521 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 6
+// Regression tests for standalone `#pragma omp tile` lowering (no consuming
+// directive). The intra-tile loop is emitted in its min-bounded form
+//   for (.tile.iv = .floor.iv; .tile.iv < min(.floor.iv + tilesize, N); 
++.tile.iv)
+// so the upper bound is materialized as a `min()` (cond.true/cond.false/phi 
over
+// the two `.tile_*.iv`/`.floor_*.iv` counters). There is no `.tile.cnt`
+// rectangular counter and no body-guard predicate here; those only appear 
when a
+// directive (e.g. `collapse`) consumes the tile -- see
+// tile_collapse_reinterpret_codegen.cpp.
+//
+// RUN: %clang_cc1 -verify -triple x86_64-pc-linux-gnu -fopenmp -emit-llvm -o 
- %s | FileCheck %s --check-prefix=IR
+// expected-no-diagnostics
+
+extern "C" void body(int);
+
+// Trip count 6, tile 4 → the last tile is partial; the min() upper bound stops
+// the tile loop at the trip count (no separate body guard).
+// IR-LABEL: define dso_local void @_Z18remainder_6_tile_4v(
+// IR-SAME: ) #[[ATTR0:[0-9]+]] {
+// IR-NEXT:  [[ENTRY:.*:]]
+// IR-NEXT:    [[I:%.*]] = alloca i32, align 4
+// IR-NEXT:    [[DOTFLOOR_0_IV_I:%.*]] = alloca i32, align 4
+// IR-NEXT:    [[DOTTILE_0_IV_I:%.*]] = alloca i32, align 4
+// IR-NEXT:    store i32 0, ptr [[I]], align 4
+// IR-NEXT:    store i32 0, ptr [[DOTFLOOR_0_IV_I]], align 4
+// IR-NEXT:    br label %[[FOR_COND:.*]]
+// IR:       [[FOR_COND]]:
+// IR-NEXT:    [[TMP0:%.*]] = load i32, ptr [[DOTFLOOR_0_IV_I]], align 4
+// IR-NEXT:    [[CMP:%.*]] = icmp slt i32 [[TMP0]], 6
+// IR-NEXT:    br i1 [[CMP]], label %[[FOR_BODY:.*]], label %[[FOR_END9:.*]]
+// IR:       [[FOR_BODY]]:
+// IR-NEXT:    [[TMP1:%.*]] = load i32, ptr [[DOTFLOOR_0_IV_I]], align 4
+// IR-NEXT:    store i32 [[TMP1]], ptr [[DOTTILE_0_IV_I]], align 4
+// IR-NEXT:    br label %[[FOR_COND1:.*]]
+// IR:       [[FOR_COND1]]:
+// IR-NEXT:    [[TMP2:%.*]] = load i32, ptr [[DOTTILE_0_IV_I]], align 4
+// IR-NEXT:    [[TMP3:%.*]] = load i32, ptr [[DOTFLOOR_0_IV_I]], align 4
+// IR-NEXT:    [[ADD:%.*]] = add nsw i32 [[TMP3]], 4
+// IR-NEXT:    [[CMP2:%.*]] = icmp slt i32 6, [[ADD]]
+// IR-NEXT:    br i1 [[CMP2]], label %[[COND_TRUE:.*]], label 
%[[COND_FALSE:.*]]
+// IR:       [[COND_TRUE]]:
+// IR-NEXT:    br label %[[COND_END:.*]]
+// IR:       [[COND_FALSE]]:
+// IR-NEXT:    [[TMP4:%.*]] = load i32, ptr [[DOTFLOOR_0_IV_I]], align 4
+// IR-NEXT:    [[ADD3:%.*]] = add nsw i32 [[TMP4]], 4
+// IR-NEXT:    br label %[[COND_END]]
+// IR:       [[COND_END]]:
+// IR-NEXT:    [[COND:%.*]] = phi i32 [ 6, %[[COND_TRUE]] ], [ [[ADD3]], 
%[[COND_FALSE]] ]
+// IR-NEXT:    [[CMP4:%.*]] = icmp slt i32 [[TMP2]], [[COND]]
+// IR-NEXT:    br i1 [[CMP4]], label %[[FOR_BODY5:.*]], label %[[FOR_END:.*]]
+// IR:       [[FOR_BODY5]]:
+// IR-NEXT:    [[TMP5:%.*]] = load i32, ptr [[DOTTILE_0_IV_I]], align 4
+// IR-NEXT:    [[MUL:%.*]] = mul nsw i32 [[TMP5]], 1
+// IR-NEXT:    [[ADD6:%.*]] = add nsw i32 0, [[MUL]]
+// IR-NEXT:    store i32 [[ADD6]], ptr [[I]], align 4
+// IR-NEXT:    [[TMP6:%.*]] = load i32, ptr [[I]], align 4
+// IR-NEXT:    call void @body(i32 noundef [[TMP6]])
+// IR-NEXT:    br label %[[FOR_INC:.*]]
+// IR:       [[FOR_INC]]:
+// IR-NEXT:    [[TMP7:%.*]] = load i32, ptr [[DOTTILE_0_IV_I]], align 4
+// IR-NEXT:    [[INC:%.*]] = add nsw i32 [[TMP7]], 1
+// IR-NEXT:    store i32 [[INC]], ptr [[DOTTILE_0_IV_I]], align 4
+// IR-NEXT:    br label %[[FOR_COND1]], !llvm.loop [[LOOP2:![0-9]+]]
+// IR:       [[FOR_END]]:
+// IR-NEXT:    br label %[[FOR_INC7:.*]]
+// IR:       [[FOR_INC7]]:
+// IR-NEXT:    [[TMP8:%.*]] = load i32, ptr [[DOTFLOOR_0_IV_I]], align 4
+// IR-NEXT:    [[ADD8:%.*]] = add nsw i32 [[TMP8]], 4
+// IR-NEXT:    store i32 [[ADD8]], ptr [[DOTFLOOR_0_IV_I]], align 4
+// IR-NEXT:    br label %[[FOR_COND]], !llvm.loop [[LOOP4:![0-9]+]]
+// IR:       [[FOR_END9]]:
+// IR-NEXT:    ret void
+//
+void remainder_6_tile_4(void) {
+  // Rectangular tile counter and constant tile-size bound.
+#pragma omp tile sizes(4)
----------------
loopacino wrote:

This is intentional. It is independently checking the cases where 
canonicalisation is not required (the other side of the functionality). I 
consider it is redundant with `tile_codegen.cpp` and `tile_ast_print.cpp`, and 
I can trim and maybe add  `collapse(2)` case here.    

https://github.com/llvm/llvm-project/pull/191114
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to