|
1 | | -// RUN: mlir-opt -allow-unregistered-dialect -convert-scf-to-cf -split-input-file %s | FileCheck %s |
| 1 | +// RUN: mlir-opt -allow-unregistered-dialect -convert-scf-to-cf -split-input-file %s | FileCheck %s --check-prefixes=CHECK,NO-VEC |
| 2 | +// RUN: mlir-opt -allow-unregistered-dialect -convert-scf-to-cf="enable-vectorize-hits=true" \ |
| 3 | +// RUN: -split-input-file %s | FileCheck %s --check-prefixes=CHECK,VEC |
| 4 | + |
| 5 | +// VEC: #loop_vectorize = #llvm.loop_vectorize<disable = false> |
| 6 | +// VEC-NEXT: #[[$VEC_ATTR:.+]] = #llvm.loop_annotation<vectorize = #loop_vectorize> |
2 | 7 |
|
3 | 8 | // CHECK-LABEL: func @simple_std_for_loop(%{{.*}}: index, %{{.*}}: index, %{{.*}}: index) { |
4 | 9 | // CHECK-NEXT: cf.br ^bb1(%{{.*}} : index) |
@@ -332,7 +337,8 @@ func.func @simple_parallel_reduce_loop(%arg0: index, %arg1: index, |
332 | 337 | // variable and the current partially reduced value. |
333 | 338 | // CHECK: ^[[COND]](%[[ITER:.*]]: index, %[[ITER_ARG:.*]]: f32 |
334 | 339 | // CHECK: %[[COMP:.*]] = arith.cmpi slt, %[[ITER]], %[[UB]] |
335 | | - // CHECK: cf.cond_br %[[COMP]], ^[[BODY:.*]], ^[[CONTINUE:.*]] |
| 340 | + // NO-VEC: cf.cond_br %[[COMP]], ^[[BODY:.*]], ^[[CONTINUE:.*]] |
| 341 | + // VEC: cf.cond_br %[[COMP]], ^[[BODY:.*]], ^[[CONTINUE:.*]] {loop_annotation = #[[$VEC_ATTR]]} |
336 | 342 |
|
337 | 343 | // Bodies of scf.reduce operations are folded into the main loop body. The |
338 | 344 | // result of this partial reduction is passed as argument to the condition |
@@ -366,11 +372,13 @@ func.func @parallel_reduce_loop(%arg0 : index, %arg1 : index, %arg2 : index, |
366 | 372 | // CHECK: %[[INIT2:.*]] = arith.constant 42 |
367 | 373 | // CHECK: cf.br ^[[COND_OUT:.*]](%{{.*}}, %[[INIT1]], %[[INIT2]] |
368 | 374 | // CHECK: ^[[COND_OUT]](%{{.*}}: index, %[[ITER_ARG1_OUT:.*]]: f32, %[[ITER_ARG2_OUT:.*]]: i64 |
369 | | - // CHECK: cf.cond_br %{{.*}}, ^[[BODY_OUT:.*]], ^[[CONT_OUT:.*]] |
| 375 | + // NO-VEC: cf.cond_br %{{.*}}, ^[[BODY_OUT:.*]], ^[[CONT_OUT:.*]] |
| 376 | + // VEC: cf.cond_br %{{.*}}, ^[[BODY_OUT:.*]], ^[[CONT_OUT:.*]] {loop_annotation = #[[$VEC_ATTR]]} |
370 | 377 | // CHECK: ^[[BODY_OUT]]: |
371 | 378 | // CHECK: cf.br ^[[COND_IN:.*]](%{{.*}}, %[[ITER_ARG1_OUT]], %[[ITER_ARG2_OUT]] |
372 | 379 | // CHECK: ^[[COND_IN]](%{{.*}}: index, %[[ITER_ARG1_IN:.*]]: f32, %[[ITER_ARG2_IN:.*]]: i64 |
373 | | - // CHECK: cf.cond_br %{{.*}}, ^[[BODY_IN:.*]], ^[[CONT_IN:.*]] |
| 380 | + // NO-VEC: cf.cond_br %{{.*}}, ^[[BODY_IN:.*]], ^[[CONT_IN:.*]] |
| 381 | + // VEC: cf.cond_br %{{.*}}, ^[[BODY_IN:.*]], ^[[CONT_IN:.*]] {loop_annotation = #[[$VEC_ATTR]]} |
374 | 382 | // CHECK: ^[[BODY_IN]]: |
375 | 383 | // CHECK: %[[REDUCE1:.*]] = arith.addf %[[ITER_ARG1_IN]], %{{.*}} |
376 | 384 | // CHECK: %[[REDUCE2:.*]] = arith.ori %[[ITER_ARG2_IN]], %{{.*}} |
@@ -551,7 +559,8 @@ func.func @ifs_in_parallel(%arg1: index, %arg2: index, %arg3: index, %arg4: i1, |
551 | 559 | // CHECK: cf.br ^[[LOOP_LATCH:.*]](%[[ARG0]] : index) |
552 | 560 | // CHECK: ^[[LOOP_LATCH]](%[[LOOP_IV:.*]]: index): |
553 | 561 | // CHECK: %[[LOOP_COND:.*]] = arith.cmpi slt, %[[LOOP_IV]], %[[ARG1]] : index |
554 | | - // CHECK: cf.cond_br %[[LOOP_COND]], ^[[LOOP_BODY:.*]], ^[[LOOP_CONT:.*]] |
| 562 | + // NO-VEC: cf.cond_br %[[LOOP_COND]], ^[[LOOP_BODY:.*]], ^[[LOOP_CONT:.*]] |
| 563 | + // VEC: cf.cond_br %[[LOOP_COND]], ^[[LOOP_BODY:.*]], ^[[LOOP_CONT:.*]] {loop_annotation = #[[$VEC_ATTR]]} |
555 | 564 | // CHECK: ^[[LOOP_BODY]]: |
556 | 565 | // CHECK: cf.cond_br %[[ARG3]], ^[[IF1_THEN:.*]], ^[[IF1_CONT:.*]] |
557 | 566 | // CHECK: ^[[IF1_THEN]]: |
@@ -660,7 +669,8 @@ func.func @index_switch(%i: index, %a: i32, %b: i32, %c: i32) -> i32 { |
660 | 669 | // CHECK: cf.br ^[[bb1:.*]](%[[c0]] : index) |
661 | 670 | // CHECK: ^[[bb1]](%[[arg0:.*]]: index): |
662 | 671 | // CHECK: %[[cmpi:.*]] = arith.cmpi slt, %[[arg0]], %[[num_threads]] |
663 | | -// CHECK: cf.cond_br %[[cmpi]], ^[[bb2:.*]], ^[[bb3:.*]] |
| 672 | +// NO-VEC: cf.cond_br %[[cmpi]], ^[[bb2:.*]], ^[[bb3:.*]] |
| 673 | +// VEC: cf.cond_br %[[cmpi]], ^[[bb2:.*]], ^[[bb3:.*]] {loop_annotation = #[[$VEC_ATTR]]} |
664 | 674 | // CHECK: ^[[bb2]]: |
665 | 675 | // CHECK: "test.foo"(%[[arg0]]) |
666 | 676 | // CHECK: %[[addi:.*]] = arith.addi %[[arg0]], %[[c1]] |
|
0 commit comments