@@ -199,9 +199,7 @@ class ScalarExprEmitter : public StmtVisitor<ScalarExprEmitter, mlir::Value> {
199199 llvm_unreachable (" NYI" );
200200 }
201201 mlir::Value VisitCXXBoolLiteralExpr (const CXXBoolLiteralExpr *E) {
202- mlir::Type Ty = CGF.convertType (E->getType ());
203- return Builder.create <cir::ConstantOp>(
204- CGF.getLoc (E->getExprLoc ()), Ty, Builder.getCIRBoolAttr (E->getValue ()));
202+ return Builder.getBool (E->getValue (), CGF.getLoc (E->getExprLoc ()));
205203 }
206204
207205 mlir::Value VisitCXXScalarValueInitExpr (const CXXScalarValueInitExpr *E) {
@@ -419,9 +417,7 @@ class ScalarExprEmitter : public StmtVisitor<ScalarExprEmitter, mlir::Value> {
419417 // An interesting aspect of this is that increment is always true.
420418 // Decrement does not have this property.
421419 if (isInc && type->isBooleanType ()) {
422- value = Builder.create <cir::ConstantOp>(CGF.getLoc (E->getExprLoc ()),
423- CGF.convertType (type),
424- Builder.getCIRBoolAttr (true ));
420+ value = Builder.getTrue (CGF.getLoc (E->getExprLoc ()));
425421 } else if (type->isIntegerType ()) {
426422 QualType promotedType;
427423 bool canPerformLossyDemotionCheck = false ;
@@ -2669,19 +2665,15 @@ mlir::Value ScalarExprEmitter::VisitBinLAnd(const clang::BinaryOperator *E) {
26692665 CIRGenFunction::LexicalScope lexScope{CGF, Loc,
26702666 B.getInsertionBlock ()};
26712667 CGF.currLexScope ->setAsTernary ();
2672- auto res = B.create <cir::ConstantOp>(
2673- Loc, Builder.getBoolTy (),
2674- Builder.getAttr <cir::BoolAttr>(Builder.getBoolTy (), true ));
2668+ auto res = B.create <cir::ConstantOp>(Loc, Builder.getTrueAttr ());
26752669 B.create <cir::YieldOp>(Loc, res.getRes ());
26762670 },
26772671 /* falseBuilder*/
26782672 [&](mlir::OpBuilder &b, mlir::Location Loc) {
26792673 CIRGenFunction::LexicalScope lexScope{CGF, Loc,
26802674 b.getInsertionBlock ()};
26812675 CGF.currLexScope ->setAsTernary ();
2682- auto res = b.create <cir::ConstantOp>(
2683- Loc, Builder.getBoolTy (),
2684- Builder.getAttr <cir::BoolAttr>(Builder.getBoolTy (), false ));
2676+ auto res = b.create <cir::ConstantOp>(Loc, Builder.getFalseAttr ());
26852677 b.create <cir::YieldOp>(Loc, res.getRes ());
26862678 });
26872679 B.create <cir::YieldOp>(Loc, res.getResult ());
@@ -2690,9 +2682,7 @@ mlir::Value ScalarExprEmitter::VisitBinLAnd(const clang::BinaryOperator *E) {
26902682 [&](mlir::OpBuilder &B, mlir::Location Loc) {
26912683 CIRGenFunction::LexicalScope lexScope{CGF, Loc, B.getInsertionBlock ()};
26922684 CGF.currLexScope ->setAsTernary ();
2693- auto res = B.create <cir::ConstantOp>(
2694- Loc, Builder.getBoolTy (),
2695- Builder.getAttr <cir::BoolAttr>(Builder.getBoolTy (), false ));
2685+ auto res = B.create <cir::ConstantOp>(Loc, Builder.getFalseAttr ());
26962686 B.create <cir::YieldOp>(Loc, res.getRes ());
26972687 });
26982688 return Builder.createZExtOrBitCast (ResOp.getLoc (), ResOp.getResult (), ResTy);
@@ -2738,9 +2728,7 @@ mlir::Value ScalarExprEmitter::VisitBinLOr(const clang::BinaryOperator *E) {
27382728 [&](mlir::OpBuilder &B, mlir::Location Loc) {
27392729 CIRGenFunction::LexicalScope lexScope{CGF, Loc, B.getInsertionBlock ()};
27402730 CGF.currLexScope ->setAsTernary ();
2741- auto res = B.create <cir::ConstantOp>(
2742- Loc, Builder.getBoolTy (),
2743- Builder.getAttr <cir::BoolAttr>(Builder.getBoolTy (), true ));
2731+ auto res = B.create <cir::ConstantOp>(Loc, Builder.getTrueAttr ());
27442732 B.create <cir::YieldOp>(Loc, res.getRes ());
27452733 },
27462734 /* falseBuilder*/
@@ -2763,9 +2751,7 @@ mlir::Value ScalarExprEmitter::VisitBinLOr(const clang::BinaryOperator *E) {
27632751 CIRGenFunction::LexicalScope lexScope{CGF, Loc,
27642752 B.getInsertionBlock ()};
27652753 CGF.currLexScope ->setAsTernary ();
2766- auto res = B.create <cir::ConstantOp>(
2767- Loc, Builder.getBoolTy (),
2768- Builder.getAttr <cir::BoolAttr>(Builder.getBoolTy (), true ));
2754+ auto res = B.create <cir::ConstantOp>(Loc, Builder.getTrueAttr ());
27692755 B.create <cir::YieldOp>(Loc, res.getRes ());
27702756 },
27712757 /* falseBuilder*/
@@ -2782,9 +2768,7 @@ mlir::Value ScalarExprEmitter::VisitBinLOr(const clang::BinaryOperator *E) {
27822768 CIRGenFunction::LexicalScope lexScope{CGF, Loc,
27832769 B.getInsertionBlock ()};
27842770 CGF.currLexScope ->setAsTernary ();
2785- auto res = b.create <cir::ConstantOp>(
2786- Loc, Builder.getBoolTy (),
2787- Builder.getAttr <cir::BoolAttr>(Builder.getBoolTy (), false ));
2771+ auto res = b.create <cir::ConstantOp>(Loc, Builder.getFalseAttr ());
27882772 b.create <cir::YieldOp>(Loc, res.getRes ());
27892773 });
27902774 B.create <cir::YieldOp>(Loc, res.getResult ());
0 commit comments