mirror of
https://github.com/intel/llvm.git
synced 2026-01-23 07:58:23 +08:00
[mlir][builtin] Make unrealized_conversion_cast inlineable (#139722)
Until now, `builtin.unrealized_conversion_cast` ops could not be inlined by the Inliner pass.
This commit is contained in:
committed by
GitHub
parent
53e9d3247e
commit
ff68f7115c
@@ -13,6 +13,7 @@
|
||||
#include "mlir/Transforms/InliningUtils.h"
|
||||
|
||||
#include "mlir/IR/Builders.h"
|
||||
#include "mlir/IR/BuiltinOps.h"
|
||||
#include "mlir/IR/IRMapping.h"
|
||||
#include "mlir/IR/Operation.h"
|
||||
#include "mlir/Interfaces/CallInterfaces.h"
|
||||
@@ -182,6 +183,11 @@ static bool isLegalToInline(InlinerInterface &interface, Region *src,
|
||||
IRMapping &valueMapping) {
|
||||
for (auto &block : *src) {
|
||||
for (auto &op : block) {
|
||||
// UnrealizedConversionCastOp is inlineable but cannot implement the
|
||||
// inliner interface due to layering constraints.
|
||||
if (isa<UnrealizedConversionCastOp>(op))
|
||||
continue;
|
||||
|
||||
// Check this operation.
|
||||
if (!interface.isLegalToInline(&op, insertRegion,
|
||||
shouldCloneInlinedRegion, valueMapping)) {
|
||||
|
||||
@@ -5,14 +5,18 @@
|
||||
// RUN: mlir-opt %s -inline='op-pipelines=func.func(canonicalize,cse)' | FileCheck %s --check-prefix INLINE_SIMPLIFY
|
||||
|
||||
// Inline a function that takes an argument.
|
||||
func.func @func_with_arg(%c : i32) -> i32 {
|
||||
%b = arith.addi %c, %c : i32
|
||||
return %b : i32
|
||||
func.func @func_with_arg(%arg0 : i32) -> i32 {
|
||||
%b = arith.addi %arg0, %arg0 : i32
|
||||
%c = builtin.unrealized_conversion_cast %b : i32 to i64
|
||||
%d = builtin.unrealized_conversion_cast %c : i64 to i32
|
||||
return %d : i32
|
||||
}
|
||||
|
||||
// CHECK-LABEL: func @inline_with_arg
|
||||
func.func @inline_with_arg(%arg0 : i32) -> i32 {
|
||||
// CHECK-NEXT: arith.addi
|
||||
// CHECK-NEXT: unrealized_conversion_cast
|
||||
// CHECK-NEXT: unrealized_conversion_cast
|
||||
// CHECK-NEXT: return
|
||||
|
||||
%0 = call @func_with_arg(%arg0) : (i32) -> i32
|
||||
|
||||
Reference in New Issue
Block a user