[Mlir-commits] [mlir] 7e87d03 - [MLIR][CF] Fix cf.switch parsing with result numbers (#87658)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Thu Apr 4 12:32:51 PDT 2024
Author: Keyi Zhang
Date: 2024-04-04T21:32:47+02:00
New Revision: 7e87d03b45f3ca0f6d9c09e8e9090329cc84592e
URL: https://github.com/llvm/llvm-project/commit/7e87d03b45f3ca0f6d9c09e8e9090329cc84592e
DIFF: https://github.com/llvm/llvm-project/commit/7e87d03b45f3ca0f6d9c09e8e9090329cc84592e.diff
LOG: [MLIR][CF] Fix cf.switch parsing with result numbers (#87658)
This PR should fix the parsing bug reported in
https://github.com/llvm/llvm-project/issues/87430. It allows using
result number as the `cf.switch` operand.
Added:
Modified:
mlir/lib/Dialect/ControlFlow/IR/ControlFlowOps.cpp
mlir/test/Dialect/ControlFlow/ops.mlir
Removed:
################################################################################
diff --git a/mlir/lib/Dialect/ControlFlow/IR/ControlFlowOps.cpp b/mlir/lib/Dialect/ControlFlow/IR/ControlFlowOps.cpp
index 5d11f8f6cc458b..1320db3f9e5431 100644
--- a/mlir/lib/Dialect/ControlFlow/IR/ControlFlowOps.cpp
+++ b/mlir/lib/Dialect/ControlFlow/IR/ControlFlowOps.cpp
@@ -531,8 +531,8 @@ static ParseResult parseSwitchOpCases(
failed(parser.parseSuccessor(destination)))
return failure();
if (succeeded(parser.parseOptionalLParen())) {
- if (failed(parser.parseOperandList(operands, OpAsmParser::Delimiter::None,
- /*allowResultNumber=*/false)) ||
+ if (failed(parser.parseOperandList(operands,
+ OpAsmParser::Delimiter::None)) ||
failed(parser.parseColonTypeList(operandTypes)) ||
failed(parser.parseRParen()))
return failure();
diff --git a/mlir/test/Dialect/ControlFlow/ops.mlir b/mlir/test/Dialect/ControlFlow/ops.mlir
index 8453c2b7038f14..c9317c76139726 100644
--- a/mlir/test/Dialect/ControlFlow/ops.mlir
+++ b/mlir/test/Dialect/ControlFlow/ops.mlir
@@ -38,3 +38,16 @@ func.func @switch_i64(%flag : i64, %caseOperand : i32) {
^bb3(%bb3arg : i32):
return
}
+
+// CHECK-LABEL: func @switch_result_number
+func.func @switch_result_number(%arg0: i32) {
+ %0:2 = "test.op_with_two_results"() : () -> (i32, i32)
+ cf.switch %arg0 : i32, [
+ default: ^bb2,
+ 0: ^bb1(%0#0 : i32)
+ ]
+ ^bb1(%1: i32):
+ return
+ ^bb2:
+ return
+}
More information about the Mlir-commits
mailing list