[Mlir-commits] [mlir] [mlir] Use arith max or min ops instead of cmp + select (PR #82178)
Jeff Niu
llvmlistbot at llvm.org
Wed Feb 21 06:43:07 PST 2024
================
@@ -48,13 +43,17 @@ static Value buildMinMaxReductionSeq(Location loc,
arith::CmpIPredicate predicate,
ValueRange values, OpBuilder &builder) {
assert(!values.empty() && "empty min/max chain");
+ assert(predicate == arith::CmpIPredicate::sgt ||
+ predicate == arith::CmpIPredicate::slt);
auto valueIt = values.begin();
Value value = *valueIt++;
for (; valueIt != values.end(); ++valueIt) {
- auto cmpOp = builder.create<arith::CmpIOp>(loc, predicate, value, *valueIt);
- value = builder.create<arith::SelectOp>(loc, cmpOp.getResult(), value,
- *valueIt);
+ if (predicate == arith::CmpIPredicate::sgt) {
----------------
Mogball wrote:
style: drop trivial braces
https://github.com/llvm/llvm-project/pull/82178
More information about the Mlir-commits
mailing list