diff --git a/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp b/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp --- a/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp +++ b/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp @@ -1551,8 +1551,8 @@ y = rewriter.create(loc, y, yOffset); x = rewriter.create(loc, x, xOffset); - iy = rewriter.create(loc, y, yScaleN); - ix = rewriter.create(loc, x, xScaleN); + iy = rewriter.create(loc, y, yScaleN); + ix = rewriter.create(loc, x, xScaleN); Value tempY = rewriter.create(loc, iy, yScaleN); Value tempX = rewriter.create(loc, ix, xScaleN); @@ -1577,14 +1577,12 @@ xPred = rewriter.create(loc, arith::CmpFPredicate::OGE, dx, halfVal); } else { - Value yScaleNHalfVal = - rewriter.create(loc, yScaleN, oneVal); - Value xScaleNHalfVal = - rewriter.create(loc, xScaleN, oneVal); + Value dyDoubled = rewriter.create(loc, dy, oneVal); + Value dxDoubled = rewriter.create(loc, dx, oneVal); yPred = rewriter.create(loc, arith::CmpIPredicate::sge, - dy, yScaleNHalfVal); + dyDoubled, yScaleN); xPred = rewriter.create(loc, arith::CmpIPredicate::sge, - dx, xScaleNHalfVal); + dxDoubled, xScaleN); } auto yOffset = diff --git a/mlir/test/Conversion/TosaToLinalg/tosa-to-linalg-resize.mlir b/mlir/test/Conversion/TosaToLinalg/tosa-to-linalg-resize.mlir --- a/mlir/test/Conversion/TosaToLinalg/tosa-to-linalg-resize.mlir +++ b/mlir/test/Conversion/TosaToLinalg/tosa-to-linalg-resize.mlir @@ -145,8 +145,8 @@ // CHECK: %[[TEMP_X:.*]] = arith.muli %[[X]], %[[SCALE_X_D]] // CHECK: %[[Y:.*]] = arith.addi %[[TEMP_Y]], %[[OFFSET_Y]] // CHECK: %[[X:.*]] = arith.addi %[[TEMP_X]], %[[OFFSET_X]] - // CHECK: %[[I_Y:.*]] = arith.divui %[[Y]], %[[SCALE_Y_N]] - // CHECK: %[[I_X:.*]] = arith.divui %[[X]], %[[SCALE_X_N]] + // CHECK: %[[I_Y:.*]] = arith.divsi %[[Y]], %[[SCALE_Y_N]] + // CHECK: %[[I_X:.*]] = arith.divsi %[[X]], %[[SCALE_X_N]] // CHECK: %[[TEMP_Y:.*]] = arith.muli %[[I_Y]], %[[SCALE_Y_N]] // CHECK: %[[TEMP_X:.*]] = arith.muli %[[I_X]], %[[SCALE_X_N]] // CHECK: %[[D_Y:.*]] = arith.subi %[[Y]], %[[TEMP_Y]] @@ -156,10 +156,10 @@ // CHECK-DAG: %[[ZERO:.*]] = arith.constant 0 // CHECK-DAG: %[[ONE:.*]] = arith.constant 1 - // CHECK: %[[SCALE_Y_N_HALF:.*]] = arith.shrsi %[[SCALE_Y_N]], %[[ONE]] - // CHECK: %[[SCALE_X_N_HALF:.*]] = arith.shrsi %[[SCALE_X_N]], %[[ONE]] - // CHECK: %[[PRED_Y:.*]] = arith.cmpi sge, %[[D_Y]], %[[SCALE_Y_N_HALF]] - // CHECK: %[[PRED_X:.*]] = arith.cmpi sge, %[[D_X]], %[[SCALE_X_N_HALF]] + // CHECK: %[[D_Y_DOUBLE:.*]] = arith.shli %[[D_Y]], %[[ONE]] + // CHECK: %[[D_X_DOUBLE:.*]] = arith.shli %[[D_X]], %[[ONE]] + // CHECK: %[[PRED_Y:.*]] = arith.cmpi sge, %[[D_Y_DOUBLE]], %[[SCALE_Y_N]] + // CHECK: %[[PRED_X:.*]] = arith.cmpi sge, %[[D_X_DOUBLE]], %[[SCALE_X_N]] // CHECK: %[[VAL_37:.*]] = arith.select %[[PRED_Y]], %[[ONE]], %[[ZERO]] // CHECK: %[[VAL_38:.*]] = arith.select %[[PRED_X]], %[[ONE]], %[[ZERO]] // CHECK: %[[VAL_39:.*]] = arith.addi %[[I_Y]], %[[VAL_37]] @@ -217,8 +217,8 @@ // CHECK: %[[TEMP_X:.*]] = arith.muli %[[X]], %[[SCALE_X_D]] // CHECK: %[[Y:.*]] = arith.addi %[[TEMP_Y]], %[[OFFSET_Y]] // CHECK: %[[X:.*]] = arith.addi %[[TEMP_X]], %[[OFFSET_X]] - // CHECK: %[[I_Y:.*]] = arith.divui %[[Y]], %[[SCALE_Y_N]] - // CHECK: %[[I_X:.*]] = arith.divui %[[X]], %[[SCALE_X_N]] + // CHECK: %[[I_Y:.*]] = arith.divsi %[[Y]], %[[SCALE_Y_N]] + // CHECK: %[[I_X:.*]] = arith.divsi %[[X]], %[[SCALE_X_N]] // CHECK: %[[TEMP_Y:.*]] = arith.muli %[[I_Y]], %[[SCALE_Y_N]] // CHECK: %[[TEMP_X:.*]] = arith.muli %[[I_X]], %[[SCALE_X_N]] // CHECK: %[[D_Y:.*]] = arith.subi %[[Y]], %[[TEMP_Y]]