Skip to content

Commit 93578ca

Browse files
Format
1 parent 3c42682 commit 93578ca

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

clang/lib/CIR/CodeGen/CIRGenBuiltinX86.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,16 @@ static mlir::Value emitIntrinsicCallOp(CIRGenFunction &cgf, const CallExpr *e,
4141

4242
static mlir::Value emitPrefetch(CIRGenFunction &cgf, unsigned builtinID,
4343
const CallExpr *e,
44-
mlir::Value &addr, int64_t hint) {
44+
const SmallVector<mlir::Value> &ops) {
4545
CIRGenBuilderTy &builder = cgf.getBuilder();
4646
mlir::Location location = cgf.getLoc(e->getExprLoc());
4747
mlir::Type voidTy = builder.getVoidTy();
48-
mlir::Value address = builder.createPtrBitcast(addr, voidTy);
48+
mlir::Value address = builder.createPtrBitcast(ops[0], voidTy);
4949
bool isWrite{};
5050
int locality{};
5151

5252
if (builtinID == X86::BI_mm_prefetch) {
53+
int hint = getIntValueFromConstOp(ops[1]);
5354
isWrite = (hint >> 2) & 0x1;
5455
locality = hint & 0x3;
5556
} else {
@@ -116,7 +117,7 @@ mlir::Value CIRGenFunction::emitX86BuiltinExpr(unsigned builtinID,
116117
case X86::BI_mm_prefetch:
117118
case X86::BI_m_prefetch:
118119
case X86::BI_m_prefetchw:
119-
return emitPrefetch(*this, builtinID, e, ops[0], getIntValueFromConstOp(ops[1]));
120+
return emitPrefetch(*this, builtinID, e, ops);
120121
case X86::BI__rdtsc:
121122
case X86::BI__builtin_ia32_rdtscp:
122123
case X86::BI__builtin_ia32_lzcnt_u16:

clang/test/CIR/CodeGen/X86/prefetchw-builtin.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,6 @@
1515

1616
#include <x86intrin.h>
1717

18-
void test_m_prefetch(void *p) {
19-
// CIR-LABEL: test_m_prefetch
20-
// LLVM-LABEL: test_m_prefetch
21-
// OGCG-LABEL: test_m_prefetch
22-
return _m_prefetch(p);
23-
// CIR: cir.prefetch read locality(0) %{{.*}} : !cir.ptr<!void>
24-
// LLVM: call void @llvm.prefetch.p0(ptr {{.*}}, i32 0, i32 0, i32 1)
25-
// OGCG: call void @llvm.prefetch.p0(ptr {{.*}}, i32 0, i32 0, i32 1)
26-
}
27-
2818
void test_m_prefetch_w(void *p) {
2919
// CIR-LABEL: test_m_prefetch_w
3020
// LLVM-LABEL: test_m_prefetch_w
@@ -34,3 +24,13 @@ void test_m_prefetch_w(void *p) {
3424
// LLVM: call void @llvm.prefetch.p0(ptr {{.*}}, i32 0, i32 0, i32 1)
3525
// OGCG: call void @llvm.prefetch.p0(ptr {{.*}}, i32 0, i32 0, i32 1)
3626
}
27+
28+
void test_m_prefetch(void *p) {
29+
// CIR-LABEL: test_m_prefetch
30+
// LLVM-LABEL: test_m_prefetch
31+
// OGCG-LABEL: test_m_prefetch
32+
return _m_prefetch(p);
33+
// CIR: cir.prefetch read locality(0) %{{.*}} : !cir.ptr<!void>
34+
// LLVM: call void @llvm.prefetch.p0(ptr {{.*}}, i32 0, i32 0, i32 1)
35+
// OGCG: call void @llvm.prefetch.p0(ptr {{.*}}, i32 0, i32 0, i32 1)
36+
}

0 commit comments

Comments
 (0)