//===----------------------------------------------------------------------===//
OpFoldResult arith::MaxFOp::fold(ArrayRef<Attribute> operands) {
+ assert(operands.size() == 2 && "maxf takes two operands");
+
// maxf(x,x) -> x
if (getLhs() == getRhs())
return getRhs();
//===----------------------------------------------------------------------===//
OpFoldResult MaxSIOp::fold(ArrayRef<Attribute> operands) {
+ assert(operands.size() == 2 && "binary operation takes two operands");
+
// maxsi(x,x) -> x
if (getLhs() == getRhs())
return getRhs();
//===----------------------------------------------------------------------===//
OpFoldResult MaxUIOp::fold(ArrayRef<Attribute> operands) {
+ assert(operands.size() == 2 && "binary operation takes two operands");
+
// maxui(x,x) -> x
if (getLhs() == getRhs())
return getRhs();
//===----------------------------------------------------------------------===//
OpFoldResult arith::MinFOp::fold(ArrayRef<Attribute> operands) {
+ assert(operands.size() == 2 && "minf takes two operands");
+
// minf(x,x) -> x
if (getLhs() == getRhs())
return getRhs();
//===----------------------------------------------------------------------===//
OpFoldResult MinSIOp::fold(ArrayRef<Attribute> operands) {
+ assert(operands.size() == 2 && "binary operation takes two operands");
+
// minsi(x,x) -> x
if (getLhs() == getRhs())
return getRhs();
//===----------------------------------------------------------------------===//
OpFoldResult MinUIOp::fold(ArrayRef<Attribute> operands) {
+ assert(operands.size() == 2 && "binary operation takes two operands");
+
// minui(x,x) -> x
if (getLhs() == getRhs())
return getRhs();
//===----------------------------------------------------------------------===//
OpFoldResult arith::TruncIOp::fold(ArrayRef<Attribute> operands) {
+ assert(operands.size() == 1 && "unary operation takes one operand");
+
// trunci(zexti(a)) -> a
// trunci(sexti(a)) -> a
if (matchPattern(getOperand(), m_Op<arith::ExtUIOp>()) ||
/// Perform safe const propagation for truncf, i.e. only propagate if FP value
/// can be represented without precision loss or rounding.
OpFoldResult arith::TruncFOp::fold(ArrayRef<Attribute> operands) {
+ assert(operands.size() == 1 && "unary operation takes one operand");
+
auto constOperand = operands.front();
if (!constOperand || !constOperand.isa<FloatAttr>())
return {};
}
OpFoldResult arith::BitcastOp::fold(ArrayRef<Attribute> operands) {
+ assert(operands.size() == 1 && "bitcast op expects 1 operand");
+
auto resType = getType();
auto operand = operands[0];
if (!operand)
}
OpFoldResult arith::CmpIOp::fold(ArrayRef<Attribute> operands) {
+ assert(operands.size() == 2 && "cmpi takes two operands");
+
// cmpi(pred, x, x)
if (getLhs() == getRhs()) {
auto val = applyCmpPredicateToEqualOperands(getPredicate());
}
OpFoldResult arith::CmpFOp::fold(ArrayRef<Attribute> operands) {
+ assert(operands.size() == 2 && "cmpf takes two operands");
+
auto lhs = operands.front().dyn_cast_or_null<FloatAttr>();
auto rhs = operands.back().dyn_cast_or_null<FloatAttr>();