Skip to content

Commit 4ddf35b

Browse files
authored
[CINN] Avoid to produce Sub node when simplify expr (#76334)
1 parent 06a66ea commit 4ddf35b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

paddle/cinn/optim/simplify_util.cc

100755100644
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,9 @@ ir::IndexExpr ConstructIndexExprByNodeType(const ir::IrNodeTy &ty,
298298
case ir::IrNodeTy::Add:
299299
return simplify_flag ? lhs + rhs : ir::Add::Make(lhs, rhs);
300300
case ir::IrNodeTy::Sub:
301-
return simplify_flag ? lhs - rhs : ir::Sub::Make(lhs, rhs);
301+
return simplify_flag
302+
? lhs - rhs
303+
: ir::Add::Make(lhs, ir::Mul::Make(rhs, ir::IndexExpr(-1)));
302304
case ir::IrNodeTy::Mul:
303305
return simplify_flag ? lhs * rhs : ir::Mul::Make(lhs, rhs);
304306
case ir::IrNodeTy::Div:

0 commit comments

Comments
 (0)