@@ -1540,6 +1540,18 @@ def Arith_CmpFOp : Arith_CompareOp<"cmpf",
1540
1540
// SelectOp
1541
1541
//===----------------------------------------------------------------------===//
1542
1542
1543
+ class AnyBooleanTypeMatch<list<string> names> :
1544
+ AnyMatchOperatorTrait<names, "$_self.getType().isSignlessInteger(1)",
1545
+ "scalar type">;
1546
+
1547
+ class ScalarConditionOrMatchingShape<list<string> names> :
1548
+ PredOpTrait<
1549
+ !head(names) # " is scalar or has matching shape",
1550
+ Or<[AnyBooleanTypeMatch<[!head(names)]>.predicate,
1551
+ AllShapesMatch<names>.predicate]>> {
1552
+ list<string> values = names;
1553
+ }
1554
+
1543
1555
def SelectOp : Arith_Op<"select", [Pure,
1544
1556
AllTypesMatch<["true_value", "false_value", "result"]>,
1545
1557
ScalarConditionOrMatchingShape<["condition", "result"]>,
@@ -1548,16 +1560,16 @@ def SelectOp : Arith_Op<"select", [Pure,
1548
1560
let summary = "select operation";
1549
1561
let description = [{
1550
1562
The `arith.select` operation chooses one value based on a binary condition
1551
- supplied as its first operand.
1552
-
1553
- If the value of the first operand (the condition) is `1`, then the second
1554
- operand is returned, and the third operand is ignored, even if it was poison.
1555
-
1556
- If the value of the first operand (the condition) is `0`, then the third
1557
- operand is returned, and the second operand is ignored, even if it was poison.
1558
-
1559
- If the value of the first operand (the condition) is poison, then the
1560
- operation returns poison.
1563
+ supplied as its first operand.
1564
+
1565
+ If the value of the first operand (the condition) is `1`, then the second
1566
+ operand is returned, and the third operand is ignored, even if it was poison.
1567
+
1568
+ If the value of the first operand (the condition) is `0`, then the third
1569
+ operand is returned, and the second operand is ignored, even if it was poison.
1570
+
1571
+ If the value of the first operand (the condition) is poison, then the
1572
+ operation returns poison.
1561
1573
1562
1574
The operation applies to vectors and tensors elementwise given the _shape_
1563
1575
of all operands is identical. The choice is made for each element
0 commit comments