summaryrefslogtreecommitdiff
path: root/mlir/test/Bytecode/uselist_orders.mlir
blob: b8f4c3df6542c267b38cbe470ca2e58e015b00a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// RUN: mlir-opt %s -split-input-file --test-verify-uselistorder -verify-diagnostics

// COM: --test-verify-uselistorder will randomly shuffle the uselist of every
//      value and do a roundtrip to bytecode. An error is returned if the
//      uselist order are not preserved when doing a roundtrip to bytecode. The
//      test needs to verify diagnostics to be functional.

func.func @base_test(%arg0 : i32) -> i32 {
  %0 = arith.constant 45 : i32
  %1 = arith.constant 46 : i32
  %2 = "test.addi"(%arg0, %arg0) : (i32, i32) -> i32
  %3 = "test.addi"(%2, %0) : (i32, i32) -> i32
  %4 = "test.addi"(%2, %1) : (i32, i32) -> i32
  %5 = "test.addi"(%3, %4) : (i32, i32) -> i32
  %6 = "test.addi"(%5, %4) : (i32, i32) -> i32
  %7 = "test.addi"(%6, %4) : (i32, i32) -> i32
  return %7 : i32
}

// -----

func.func @test_with_multiple_uses_in_same_op(%arg0 : i32) -> i32 {
  %0 = arith.constant 45 : i32
  %1 = arith.constant 46 : i32
  %2 = "test.addi"(%arg0, %arg0) : (i32, i32) -> i32
  %3 = "test.addi"(%2, %0) : (i32, i32) -> i32
  %4 = "test.addi"(%2, %1) : (i32, i32) -> i32
  %5 = "test.addi"(%2, %2) : (i32, i32) -> i32
  %6 = "test.addi"(%3, %4) : (i32, i32) -> i32
  %7 = "test.addi"(%6, %5) : (i32, i32) -> i32
  %8 = "test.addi"(%7, %4) : (i32, i32) -> i32
  %9 = "test.addi"(%8, %4) : (i32, i32) -> i32
  return %9 : i32
}

// -----

func.func @test_with_multiple_block_arg_uses(%arg0 : i32) -> i32 {
  %0 = arith.constant 45 : i32
  %1 = arith.constant 46 : i32
  %2 = "test.addi"(%arg0, %arg0) : (i32, i32) -> i32
  %3 = "test.addi"(%2, %arg0) : (i32, i32) -> i32
  %4 = "test.addi"(%2, %1) : (i32, i32) -> i32
  %5 = "test.addi"(%2, %2) : (i32, i32) -> i32
  %6 = "test.addi"(%3, %4) : (i32, i32) -> i32
  %7 = "test.addi"(%6, %5) : (i32, i32) -> i32
  %8 = "test.addi"(%7, %4) : (i32, i32) -> i32
  %9 = "test.addi"(%8, %4) : (i32, i32) -> i32
  return %9 : i32
}

// -----

// Test that use-lists in region with no dominance are preserved
test.graph_region {
  %0 = "test.foo"(%1) : (i32) -> i32
  test.graph_region attributes {a} {
    %a = "test.a"(%b) : (i32) -> i32
    %b = "test.b"(%2) : (i32) -> i32
  }
  %1 = "test.bar"(%2) : (i32) -> i32
  %2 = "test.baz"() : () -> i32
}