================ @@ -749,6 +749,7 @@ mlir::Value ComplexExprEmitter::emitPromoted(const Expr *e, HANDLE_BINOP(Add) HANDLE_BINOP(Sub) HANDLE_BINOP(Mul) + HANDLE_BINOP(Div) ---------------- AmrDeveloper wrote:
For this test case, when the promotion type is not null The old code path. - in emitPromoted will go to the else path ``` mlir::Value result = Visit(const_cast<Expr *>(e)); if (!promotionTy.isNull()) return cgf.emitPromotedValue(result, promotionTy); ``` Which means visitBinDivOp, which will call emitBinOps and will promote the type `f16 -> f32`, then will un-promote it ``` if (!promotionTy.isNull()) result = cgf.emitUnPromotedValue(result, e->getType()); ``` And when it goes back to emitPromoted after the visit call it will promote it again (The first code snippet) With the current solution, it will promote the type and go directly to `emitBinDiv`, then early return from emitPromoted that eliminates unnecessary casts When I print with passes disabled, I found that the old approach emits 2 more casts to promote and unpromote the type https://github.com/llvm/llvm-project/pull/156963 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits