Skip to content

Commit 1399dd5

Browse files
ghehgxlauko
authored andcommitted
[CIR][CIRGen][Builtin] Support __builtin_elementwise_abs with vector of floating type (llvm#1174)
[PR1132](llvm/clangir#1132) implements missing feature `fpUnaryOPsSupportVectorType`, so revisit this code. One another thing changed is that I stopped using `cir::isAnyFloatingPointType` as it contains types like long double and FP80 which are not supported by the [builtin's signature](https://clang.llvm.org/docs/LanguageExtensions.html#vector-builtins)
1 parent b345536 commit 1399dd5

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

clang/include/clang/CIR/MissingFeatures.h

-3
Original file line numberDiff line numberDiff line change
@@ -410,9 +410,6 @@ struct MissingFeatures {
410410

411411
//-- Other missing features
412412

413-
// We need to extend fpUnaryOPs to support vector types.
414-
static bool fpUnaryOPsSupportVectorType() { return false; }
415-
416413
// We need to track the parent record types that represent a field
417414
// declaration. This is necessary to determine the layout of a class.
418415
static bool fieldDeclAbstraction() { return false; }

clang/lib/CIR/CodeGen/CIRGenBuiltin.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -3124,10 +3124,12 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
31243124
mlir::Type cirTy = ConvertType(E->getArg(0)->getType());
31253125
bool isIntTy = cir::isIntOrIntVectorTy(cirTy);
31263126
if (!isIntTy) {
3127-
if (cir::isAnyFloatingPointType(cirTy)) {
3127+
mlir::Type eltTy = cirTy;
3128+
if (mlir::isa<cir::VectorType>(cirTy))
3129+
eltTy = mlir::cast<cir::VectorType>(cirTy).getEltType();
3130+
if (mlir::isa<cir::SingleType, cir::DoubleType>(eltTy)) {
31283131
return emitUnaryFPBuiltin<cir::FAbsOp>(*this, *E);
31293132
}
3130-
assert(!MissingFeatures::fpUnaryOPsSupportVectorType());
31313133
llvm_unreachable("unsupported type for BI__builtin_elementwise_abs");
31323134
}
31333135
mlir::Value arg = emitScalarExpr(E->getArg(0));

0 commit comments

Comments
 (0)