================
@@ -828,14 +810,48 @@ 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) {
+    assert(cir::isFPOrVectorOfFPType(input.getType()) &&
+           "Expect floating-point operand");
+    mlir::Location loc = cgf.getLoc(e->getSourceRange().getBegin());
+
+    if (auto vecType = mlir::dyn_cast<cir::VectorType>(input.getType())) {
+      mlir::Type fpScalarType = vecType.getElementType();
+      auto fpInterface = mlir::cast<cir::FPTypeInterface>(fpScalarType);
+      mlir::Value amount = builder.getConstFP(
+          loc, fpScalarType, llvm::APFloat(fpInterface.getFloatSemantics(), 
1));
+      amount = cir::VecSplatOp::create(builder, loc, vecType, amount);
+      return e->isIncrementOp() ? builder.createFAdd(loc, input, amount)
----------------
Luhaocong wrote:

Done, address all comments.
1. Using `fadd -1` for `e->isDecrementOp()`, aligned to OGCG:
```
      auto amount = llvm::APFloat::getOne(fpInterface.getFloatSemantics(),
                                          /*Negative=*/e->isDecrementOp());
      mlir::Value amtValue = builder.getConstFP(loc, input.getType(), amount);
      mlir::Value output = builder.createFAdd(loc, input, amtValue);
```
2. Add LLVM /OGCG checking lines for `char` test case , and rename `CHECK` to 
`CIR` in `unary.cpp`.
3. Remove test file `unary-inc-dec-unsupport.cpp`.
4. Merge `unary-inc-dec-vector.cpp` into `unary.cpp` (additional option 
-fzvector).

https://github.com/llvm/llvm-project/pull/193215
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to