[clang] [CIR] Upstream missing support for floating point unary operator (PR #193215)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 28 10:02:20 PDT 2026
================
@@ -825,14 +818,23 @@ class ScalarExprEmitter : public StmtVisitor<ScalarExprEmitter, mlir::Value> {
return builder.createOrFold<cir::MinusOp>(loc, operand, nsw);
}
- mlir::Value emitIncOrDec(const UnaryOperator *e, mlir::Value input,
- bool nsw = false) {
+ mlir::Value emitIntIncOrDec(const UnaryOperator *e, mlir::Value input,
+ bool nsw = false) {
mlir::Location loc = cgf.getLoc(e->getSourceRange().getBegin());
return e->isIncrementOp()
? builder.createOrFold<cir::IncOp>(loc, input, nsw)
: builder.createOrFold<cir::DecOp>(loc, input, nsw);
}
+ mlir::Value emitFloatIncOrDec(const UnaryOperator *e, mlir::Value input) {
+ mlir::Location loc = cgf.getLoc(e->getSourceRange().getBegin());
+ auto fpType = mlir::cast<cir::FPTypeInterface>(input.getType());
+ mlir::Value amount = builder.getConstFP(
+ loc, input.getType(), llvm::APFloat(fpType.getFloatSemantics(), 1));
+ return e->isIncrementOp() ? builder.createFAdd(loc, input, amount)
----------------
erichkeane wrote:
Huh, we do! I think my mind is changed, inc/dec add little/no value (And perhaps are harmful!). I DO think we probably could/should/will have a pattern to recognize inc/dec for the above purposes, but that is irrelevant here/etc.
So I'll resolve this one.
https://github.com/llvm/llvm-project/pull/193215
More information about the cfe-commits
mailing list