23 lines · plain
1// RUN: mlir-opt %s --loop-invariant-code-motion | FileCheck %s2 3func.func private @side_effect(%arg0 : f32, %arg1 : f32)4 5// CHECK-LABEL: func @broadcast_hoisting6// CHECK-SAME: (%[[ARG:.*]]: f32, %[[IDX:.*]]: i32, {{.*}}: index)7func.func @broadcast_hoisting(%arg0 : f32, %arg1 : i32, %arg2 : index) {8 %c0 = arith.constant 0 : index9 %c1 = arith.constant 1 : index10// `specific_lane` can be speculated across the control flow, but11// `first_active_lane` cannot as active lanes can change.12// CHECK: %[[V1:.*]] = gpu.subgroup_broadcast %[[ARG]], specific_lane %[[IDX]] : f3213// CHECK: scf.for14// CHECK: %[[V0:.*]] = gpu.subgroup_broadcast %[[ARG]], first_active_lane : f3215// CHECK: func.call @side_effect(%[[V0]], %[[V1]])16 scf.for %i = %c0 to %arg2 step %c1 {17 %0 = gpu.subgroup_broadcast %arg0, first_active_lane : f3218 %1 = gpu.subgroup_broadcast %arg0, specific_lane %arg1 : f3219 func.call @side_effect(%0, %1) : (f32, f32) -> ()20 }21 func.return22}23