brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.8 KiB · 7b4557d Raw
60 lines · plain
1// RUN: mlir-opt -llvm-legalize-for-export --split-input-file  %s | FileCheck %s2 3// Verifies that duplicate successor with different arguments are deduplicated4// by introducing a new block that forwards its arguments to the original5// successor through an unconditional branch.6// CHECK-LABEL: @repeated_successor_different_args7llvm.func @repeated_successor_different_args(%arg0: i1, %arg1: i32, %arg2: i32) {8  // CHECK: llvm.cond_br %{{.*}}, ^[[BB1:.*]]({{.*}}), ^[[BB2:.*]]({{.*}})9  llvm.cond_br %arg0, ^bb1(%arg1: i32), ^bb1(%arg2: i32)10 11// CHECK: ^[[BB1]]({{.*}}):12^bb1(%arg3: i32):13  llvm.return14 15// CHECK: ^[[BB2]](%[[ARG:.*]]: i32):16// CHECK:  llvm.br ^[[BB1]](%[[ARG]] : i32)17}18 19// Verifies that duplicate successors without arguments do not lead to the20// introduction of new blocks during legalization.21// CHECK-LABEL: @repeated_successor_no_args22llvm.func @repeated_successor_no_args(%arg0: i1) {23  // CHECK: llvm.cond_br24  llvm.cond_br %arg0, ^bb1, ^bb125 26// CHECK: ^{{.*}}:27^bb1:28  llvm.return29 30// CHECK-NOT: ^{{.*}}:31}32 33// CHECK: @repeated_successor_openmp34llvm.func @repeated_successor_openmp(%arg0: i64, %arg1: i64, %arg2: i64, %arg3: i1) {35  omp.wsloop {36    omp.loop_nest (%arg4) : i64 = (%arg0) to (%arg1) step (%arg2) {37      // CHECK: llvm.cond_br %{{.*}}, ^[[BB1:.*]]({{.*}}), ^[[BB2:.*]]({{.*}})38      llvm.cond_br %arg3, ^bb1(%arg0 : i64), ^bb1(%arg1 : i64)39    // CHECK: ^[[BB1]]40    ^bb1(%0: i64):  // 2 preds: ^bb0, ^bb041      omp.yield42    // CHECK: ^[[BB2]](%[[ARG:.*]]: i64):43    // CHECK:  llvm.br ^[[BB1]](%[[ARG]] : i64)44    }45  }46  llvm.return47}48 49// -----50 51// This module won't have any LLVM dialect entities as input.52// Check that we don't crash when building LLVM entities.53// CHECK-LABEL:func @func154func.func @func1(%arg0: i1, %arg1 : i1) {55// CHECK: llvm.br56  cf.cond_br %arg0, ^bb40(%arg0 : i1), ^bb40(%arg1 : i1)57^bb40(%47: i1):58  return59}60