[clang] [CIR] Update ComplexRealOp to work on scalar type (PR #161080)
Henrich Lauko via cfe-commits
cfe-commits at lists.llvm.org
Sun Sep 28 23:50:05 PDT 2025
================
@@ -148,9 +148,10 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
}
mlir::Value createComplexReal(mlir::Location loc, mlir::Value operand) {
- auto operandTy = mlir::cast<cir::ComplexType>(operand.getType());
- return cir::ComplexRealOp::create(*this, loc, operandTy.getElementType(),
- operand);
+ auto resultType = operand.getType();
+ if (mlir::isa<cir::ComplexType>(resultType))
+ resultType = mlir::cast<cir::ComplexType>(resultType).getElementType();
----------------
xlauko wrote:
```suggestion
if (auto complexResultType = mlir::dyn_cast<cir::ComplexType>(resultType))
resultType = complexResultType.getElementType();
```
https://github.com/llvm/llvm-project/pull/161080
More information about the cfe-commits
mailing list