blob: 7d21ff986c3d8c21ced0630ec35b2527d6c9f51f [file] [log] [blame]
Nicolas Vasilachef0d43a22021-06-23 09:03:081// RUN: mlir-opt -canonicalize %s -split-input-file | FileCheck %s
2
3// CHECK-LABEL: fold_extractvalue
4llvm.func @fold_extractvalue() -> i32 {
Mogballa54f4ea2021-10-12 23:14:575 // CHECK-DAG: %[[C0:.*]] = arith.constant 0 : i32
6 %c0 = arith.constant 0 : i32
7 // CHECK-DAG: %[[C1:.*]] = arith.constant 1 : i32
8 %c1 = arith.constant 1 : i32
Nicolas Vasilachef0d43a22021-06-23 09:03:089
10 %0 = llvm.mlir.undef : !llvm.struct<(i32, i32)>
11
12 // CHECK-NOT: insertvalue
13 %1 = llvm.insertvalue %c0, %0[0] : !llvm.struct<(i32, i32)>
14 %2 = llvm.insertvalue %c1, %1[1] : !llvm.struct<(i32, i32)>
15
16 // CHECK-NOT: extractvalue
17 %3 = llvm.extractvalue %2[0] : !llvm.struct<(i32, i32)>
18 %4 = llvm.extractvalue %2[1] : !llvm.struct<(i32, i32)>
19
20 // CHECK: llvm.add %[[C0]], %[[C1]]
21 %5 = llvm.add %3, %4 : i32
22 llvm.return %5 : i32
23}