Skip to content
Open
Show file tree
Hide file tree
Changes from 2 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
12 changes: 11 additions & 1 deletion clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include "clang/Basic/Builtins.h"
#include "clang/Basic/TargetBuiltins.h"
#include "clang/CIR/MissingFeatures.h"
#include "llvm/IR/IntrinsicsX86.h"

using namespace clang;
using namespace clang::CIRGen;
Expand Down Expand Up @@ -95,9 +94,20 @@ mlir::Value CIRGenFunction::emitX86BuiltinExpr(unsigned builtinID,
case X86::BI__builtin_ia32_tzcnt_u16:
case X86::BI__builtin_ia32_tzcnt_u32:
case X86::BI__builtin_ia32_tzcnt_u64:
cgm.errorNYI(e->getSourceRange(),
std::string("unimplemented X86 builtin call: ") +
getContext().BuiltinInfo.getName(builtinID));
return {};
case X86::BI__builtin_ia32_undef128:
case X86::BI__builtin_ia32_undef256:
case X86::BI__builtin_ia32_undef512:
// The x86 definition of "undef" is not the same as the LLVM definition
// (PR32176). We leave optimizing away an unnecessary zero constant to the
// IR optimizer and backend.
// TODO: If we had a "freeze" IR instruction to generate a fixed undef
// value, we should use that here instead of a zero.
return builder.getNullValue(convertType(e->getType()),
getLoc(e->getExprLoc()));
case X86::BI__builtin_ia32_vec_ext_v4hi:
case X86::BI__builtin_ia32_vec_ext_v16qi:
case X86::BI__builtin_ia32_vec_ext_v8hi:
Expand Down
23 changes: 23 additions & 0 deletions clang/test/CIR/CodeGen/X86/sse2-builtins.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,29 @@

#include <immintrin.h>

__m128d test_mm_undefined_pd(void) {
// CIR-X64-LABEL: _mm_undefined_pd
// CIR-X64: %{{.*}} = cir.const #cir.zero : !cir.vector<2 x !cir.double>
// CIR-X64: cir.return %{{.*}} : !cir.vector<2 x !cir.double>
// LLVM-X64-LABEL: test_mm_undefined_pd
// LLVM-X64: store <2 x double> zeroinitializer, ptr %[[A:.*]], align 16
// LLVM-X64: %{{.*}} = load <2 x double>, ptr %[[A]], align 16
// LLVM-X64: ret <2 x double> %{{.*}}
return _mm_undefined_pd();
}

__m128i test_mm_undefined_si128(void) {
// CIR-LABEL: _mm_undefined_si128
// CIR-CHECK: %[[A:.*]] = cir.const #cir.zero : !cir.vector<2 x !cir.double>
// CIR-CHECK: %{{.*}} = cir.cast bitcast %[[A]] : !cir.vector<2 x !cir.double> -> !cir.vector<2 x !s64i>
// CIR-CHECK: cir.return %{{.*}} : !cir.vector<2 x !s64i>

// LLVM-CHECK-LABEL: test_mm_undefined_si128
// LLVM-CHECK: store <2 x i64> zeroinitializer, ptr %[[A:.*]], align 16
// LLVM-CHECK: %{{.*}} = load <2 x i64>, ptr %[[A]], align 16
// LLVM-CHECK: ret <2 x i64> %{{.*}}
return _mm_undefined_si128();
}

void test_mm_clflush(void* A) {
// CIR-LABEL: test_mm_clflush
Expand Down
Loading