// RUN: mlir-hlo-opt --mhlo-control-flow-to-scf %s | FileCheck %s func @lt_loop(%arg0: tensor<4xf32>, %arg1: tensor, %arg2: tensor, %arg3: tensor<4xf32>, %arg4: tensor, %arg5: tensor, %arg6: tensor, %arg7: tensor, %arg8: tensor) -> (tuple, tensor, tensor>) { %cst = constant dense<-1> : tensor %cst_0 = constant dense<1> : tensor %cst_1 = constant dense<0> : tensor %cst_2 = constant dense<1000> : tensor %0 = "mhlo.tuple"(%cst_1, %cst, %cst_2) : (tensor, tensor, tensor) -> tuple, tensor, tensor> %1 = "mhlo.while"(%0) ( { ^bb0(%arg9: tuple, tensor, tensor>): // no predecessors %2 = "mhlo.get_tuple_element"(%arg9) {index = 0 : i32} : (tuple, tensor, tensor>) -> tensor %3 = "mhlo.get_tuple_element"(%arg9) {index = 2 : i32} : (tuple, tensor, tensor>) -> tensor %4 = "mhlo.compare"(%2, %3) {comparison_direction = "LT"} : (tensor, tensor) -> tensor "mhlo.return"(%4) : (tensor) -> () }, { ^bb0(%arg9: tuple, tensor, tensor>): // no predecessors %2 = "mhlo.get_tuple_element"(%arg9) {index = 0 : i32} : (tuple, tensor, tensor>) -> tensor %3 = mhlo.add %2, %cst_0 : tensor %4 = "mhlo.get_tuple_element"(%arg9) {index = 1 : i32} : (tuple, tensor, tensor>) -> tensor %5 = "mhlo.get_tuple_element"(%arg9) {index = 2 : i32} : (tuple, tensor, tensor>) -> tensor %6 = "mhlo.tuple"(%3, %4, %5) : (tensor, tensor, tensor) -> tuple, tensor, tensor> "mhlo.return"(%6) : (tuple, tensor, tensor>) -> () }) : (tuple, tensor, tensor>) -> tuple, tensor, tensor> return %1 : tuple, tensor, tensor> } // CHECK-LABEL: func @lt_loop( // CHECK: %[[VAL_9:.*]] = constant dense<-1> : tensor // CHECK: %[[VAL_10:.*]] = constant dense<1> : tensor // CHECK: %[[VAL_11:.*]] = constant dense<0> : tensor // CHECK: %[[VAL_12:.*]] = constant dense<1000> : tensor // CHECK: %[[VAL_14:.*]] = index_cast %[[VAL_11]] : tensor to tensor // CHECK: %[[VAL_15:.*]] = tensor.extract %[[VAL_14]][] : tensor // CHECK: %[[VAL_16:.*]] = index_cast %[[VAL_12]] : tensor to tensor // CHECK: %[[VAL_17:.*]] = tensor.extract %[[VAL_16]][] : tensor // CHECK: %[[VAL_18:.*]] = index_cast %[[VAL_10]] : tensor to tensor // CHECK: %[[VAL_19:.*]] = tensor.extract %[[VAL_18]][] : tensor // CHECK: scf.for %[[VAL_21:.*]] = %[[VAL_15]] to %[[VAL_17]] step %[[VAL_19]] iter_args(%[[VAL_22:.*]] = %[[VAL_9]], %[[VAL_23:.*]] = %[[VAL_12]])