@@ -1088,7 +1088,7 @@ def Arith_CmpIOp : Arith_CompareOpOfAnyRank<"cmpi"> {
10881088 %x = arith.cmpi "eq", %lhs, %rhs : vector<4xi64>
10891089
10901090 // Generic form of the same operation.
1091- %x = "std. arith.cmpi"(%lhs, %rhs) {predicate = 0 : i64}
1091+ %x = "arith.cmpi"(%lhs, %rhs) {predicate = 0 : i64}
10921092 : (vector<4xi64>, vector<4xi64>) -> vector<4xi1>
10931093 ```
10941094 }];
@@ -1161,4 +1161,55 @@ def Arith_CmpFOp : Arith_CompareOp<"cmpf"> {
11611161 let hasFolder = 1;
11621162}
11631163
1164+ //===----------------------------------------------------------------------===//
1165+ // SelectOp
1166+ //===----------------------------------------------------------------------===//
1167+
1168+ def SelectOp : Arith_Op<"select", [
1169+ AllTypesMatch<["true_value", "false_value", "result"]>
1170+ ] # ElementwiseMappable.traits> {
1171+ let summary = "select operation";
1172+ let description = [{
1173+ The `arith.select` operation chooses one value based on a binary condition
1174+ supplied as its first operand. If the value of the first operand is `1`,
1175+ the second operand is chosen, otherwise the third operand is chosen.
1176+ The second and the third operand must have the same type.
1177+
1178+ The operation applies to vectors and tensors elementwise given the _shape_
1179+ of all operands is identical. The choice is made for each element
1180+ individually based on the value at the same position as the element in the
1181+ condition operand. If an i1 is provided as the condition, the entire vector
1182+ or tensor is chosen.
1183+
1184+ Example:
1185+
1186+ ```mlir
1187+ // Custom form of scalar selection.
1188+ %x = arith.select %cond, %true, %false : i32
1189+
1190+ // Generic form of the same operation.
1191+ %x = "arith.select"(%cond, %true, %false) : (i1, i32, i32) -> i32
1192+
1193+ // Element-wise vector selection.
1194+ %vx = arith.select %vcond, %vtrue, %vfalse : vector<42xi1>, vector<42xf32>
1195+
1196+ // Full vector selection.
1197+ %vx = arith.select %cond, %vtrue, %vfalse : vector<42xf32>
1198+ ```
1199+ }];
1200+
1201+ let arguments = (ins BoolLike:$condition,
1202+ AnyType:$true_value,
1203+ AnyType:$false_value);
1204+ let results = (outs AnyType:$result);
1205+
1206+ let hasCanonicalizer = 1;
1207+ let hasFolder = 1;
1208+ let hasVerifier = 1;
1209+
1210+ // FIXME: Switch this to use the declarative assembly format.
1211+ let printer = [{ return ::print(p, *this); }];
1212+ let parser = [{ return ::parse$cppClass(parser, result); }];
1213+ }
1214+
11641215#endif // ARITHMETIC_OPS
0 commit comments