brintos

brintos / llvm-project-archived public Read only

0
0
Text · 934 B · 172945f Raw
19 lines · plain
1// Test with the default (one application of the folder) and then with 2 iterations.2// RUN: mlir-opt %s --pass-pipeline="builtin.module(func.func(test-single-fold))" | FileCheck %s --check-prefixes=CHECK,CHECK-ONE3// RUN: mlir-opt %s --pass-pipeline="builtin.module(func.func(test-single-fold{max-iterations=2}))" | FileCheck %s --check-prefixes=CHECK,CHECK-TWO4 5 6// Folding entirely this requires to move the constant to the right7// before invoking the op-specific folder.8// With one iteration, we just push the constant to the right.9// With a second iteration, we actually fold the "add" (x+0->x)10// CHECK: func @recurse_fold_traits(%[[ARG0:.*]]: i32)11func.func @recurse_fold_traits(%arg0 : i32) -> i32 {12  %cst0 = arith.constant 0 : i3213// CHECK-ONE:  %[[ADD:.*]] = arith.addi %[[ARG0]], 14  %res = arith.addi %cst0, %arg0 : i3215// CHECK-ONE:   return %[[ADD]] : i3216// CHECK-TWO:   return %[[ARG0]] : i3217  return %res : i3218}19