@@ -454,12 +454,12 @@ struct ClampIsNoOp : public OpRewritePattern<tosa::ClampOp> {
454454
455455 if (isa<FloatType>(inputElementType)) {
456456 // Unlike integer types, floating point types can represent infinity.
457- auto minClamp =
457+ const auto minClamp =
458458 llvm::cast<mlir::FloatAttr>(op.getMinValAttr ()).getValue ();
459- auto maxClamp =
459+ const auto maxClamp =
460460 llvm::cast<mlir::FloatAttr>(op.getMaxValAttr ()).getValue ();
461- bool isMin = minClamp.isNegInfinity ();
462- bool isMax = maxClamp.isInfinity ();
461+ const bool isMin = minClamp.isNegInfinity ();
462+ const bool isMax = maxClamp.isInfinity ();
463463
464464 if (isMin && isMax) {
465465 rewriter.replaceOp (op, input);
@@ -471,16 +471,16 @@ struct ClampIsNoOp : public OpRewritePattern<tosa::ClampOp> {
471471 // i1 types are boolean in TOSA
472472 const bool isBoolean = inputElementType.isInteger (1 );
473473 if (inputElementType.isUnsignedInteger () || isBoolean) {
474- int64_t minClamp = llvm::cast<mlir::IntegerAttr>(op.getMinValAttr ())
475- .getValue ()
476- .getZExtValue ();
477- int64_t maxClamp = llvm::cast<mlir::IntegerAttr>(op.getMaxValAttr ())
478- .getValue ()
479- .getZExtValue ();
474+ const int64_t minClamp = llvm::cast<mlir::IntegerAttr>(op.getMinValAttr ())
475+ .getValue ()
476+ .getZExtValue ();
477+ const int64_t maxClamp = llvm::cast<mlir::IntegerAttr>(op.getMaxValAttr ())
478+ .getValue ()
479+ .getZExtValue ();
480480
481- unsigned bitWidth = inputElementType.getIntOrFloatBitWidth ();
482- int64_t intMin = APInt::getMinValue (bitWidth).getZExtValue ();
483- int64_t intMax = APInt::getMaxValue (bitWidth).getZExtValue ();
481+ const unsigned bitWidth = inputElementType.getIntOrFloatBitWidth ();
482+ const int64_t intMin = APInt::getMinValue (bitWidth).getZExtValue ();
483+ const int64_t intMax = APInt::getMaxValue (bitWidth).getZExtValue ();
484484
485485 if (minClamp <= intMin && maxClamp >= intMax) {
486486 rewriter.replaceOp (op, input);
@@ -490,14 +490,14 @@ struct ClampIsNoOp : public OpRewritePattern<tosa::ClampOp> {
490490 }
491491
492492 if (llvm::isa<IntegerType>(inputElementType)) {
493- int64_t minClamp =
493+ const int64_t minClamp =
494494 llvm::cast<mlir::IntegerAttr>(op.getMinValAttr ()).getInt ();
495- int64_t maxClamp =
495+ const int64_t maxClamp =
496496 llvm::cast<mlir::IntegerAttr>(op.getMaxValAttr ()).getInt ();
497497
498- unsigned bitWidth = inputElementType.getIntOrFloatBitWidth ();
499- int64_t intMin = APInt::getSignedMinValue (bitWidth).getSExtValue ();
500- int64_t intMax = APInt::getSignedMaxValue (bitWidth).getSExtValue ();
498+ const unsigned bitWidth = inputElementType.getIntOrFloatBitWidth ();
499+ const int64_t intMin = APInt::getSignedMinValue (bitWidth).getSExtValue ();
500+ const int64_t intMax = APInt::getSignedMaxValue (bitWidth).getSExtValue ();
501501
502502 if (minClamp <= intMin && maxClamp >= intMax) {
503503 rewriter.replaceOp (op, input);
0 commit comments