[Mlir-commits] [mlir] [MLIR][Arith] SelectOp fix invalid folding (PR #117555)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Mon Nov 25 05:25:30 PST 2024
https://github.com/7FM created https://github.com/llvm/llvm-project/pull/117555
The pattern `select %x, true, false => %x` is only valid in case that the return type is identical to the type of `%x` (i.e., i1). Hence, the check `isInteger(1)` was replaced with `isSignlessInteger(1)`.
Fixes: https://github.com/llvm/llvm-project/issues/117554
>From c7980e72fa45d84497646796b540cfae630903e5 Mon Sep 17 00:00:00 2001
From: 7FM <41307817+7FM at users.noreply.github.com>
Date: Mon, 25 Nov 2024 14:16:47 +0100
Subject: [PATCH] [MLIR][Arith] SelectOp fix invalid folding
The pattern `select %x, true, false => %x` is only valid in case that the return type is identical to the type of `%x` (i.e., i1).
Hence, the check `isInteger(1)` was replaced with `isSignlessInteger(1)`.
---
mlir/lib/Dialect/Arith/IR/ArithOps.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/mlir/lib/Dialect/Arith/IR/ArithOps.cpp b/mlir/lib/Dialect/Arith/IR/ArithOps.cpp
index 254f54d9e459e1..f2f23954d5c191 100644
--- a/mlir/lib/Dialect/Arith/IR/ArithOps.cpp
+++ b/mlir/lib/Dialect/Arith/IR/ArithOps.cpp
@@ -2314,7 +2314,8 @@ OpFoldResult arith::SelectOp::fold(FoldAdaptor adaptor) {
return trueVal;
// select %x, true, false => %x
- if (getType().isInteger(1) && matchPattern(adaptor.getTrueValue(), m_One()) &&
+ if (getType().isSignlessInteger(1) &&
+ matchPattern(adaptor.getTrueValue(), m_One()) &&
matchPattern(adaptor.getFalseValue(), m_Zero()))
return condition;
More information about the Mlir-commits
mailing list