Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,8 @@ class ScalarExprEmitter : public StmtVisitor<ScalarExprEmitter, mlir::Value> {
assert(!cir::MissingFeatures::fpConstraints());
castKind = cir::CastKind::float_to_int;
} else if (mlir::isa<cir::CIRFPTypeInterface>(dstTy)) {
cgf.getCIRGenModule().errorNYI("floating point casts");
return cgf.createDummyValue(src.getLoc(), dstType);
// TODO: split this to createFPExt/createFPTrunc
return builder.createFloatingCast(src, fullDstTy);
} else {
llvm_unreachable("Internal error: Cast to unexpected type");
}
Expand Down
8 changes: 8 additions & 0 deletions clang/test/CIR/CodeGen/cast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ int cStyleCasts_0(unsigned x1, int x2, float x3, short x4, double x5) {
// LLVM: %{{[0-9]+}} = fcmp une float %{{[0-9]+}}, 0.000000e+00
// LLVM: %{{[0-9]+}} = zext i1 %{{[0-9]+}} to i8

double d2 = f; // float to double
// CIR: %{{[0-9]+}} = cir.cast(floating, %{{[0-9]+}} : !cir.float), !cir.double
// LLVM: %{{[0-9]+}} = fpext float %{{[0-9]+}} to double

f = d2; // double to float
// CIR: %{{[0-9]+}} = cir.cast(floating, %{{[0-9]+}} : !cir.double), !cir.float
// LLVM: %{{[0-9]+}} = fptrunc double %{{[0-9]+}} to float

return 0;
}

Expand Down
Loading