From c2a672e7cc1f6919aef67476aacce833d29ecdd1 Mon Sep 17 00:00:00 2001 From: Gabor Buella Date: Fri, 11 May 2018 14:22:04 +0000 Subject: [PATCH] [X86] Assume alignment of movdir64b dst argument Reviewers: craig.topper Reviewed By: craig.topper Differential Revision: https://reviews.llvm.org/D46683 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@332091 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Headers/movdirintrin.h | 9 +++++++-- test/CodeGen/builtin-movdir.c | 7 ++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/lib/Headers/movdirintrin.h b/lib/Headers/movdirintrin.h index 746433799a..10322e17e4 100644 --- a/lib/Headers/movdirintrin.h +++ b/lib/Headers/movdirintrin.h @@ -47,10 +47,15 @@ _directstoreu_u64 (void *__dst, unsigned long __value) #endif /* __x86_64__ */ -// Move 64 bytes as direct store +/* + * movdir64b - Move 64 bytes as direct store. + * The destination must be 64 byte aligned, and the store is atomic. + * The source address has no alignment requirement, and the load from + * the source address is not atomic. + */ static __inline__ void __attribute__((__always_inline__, __nodebug__, __target__("movdir64b"))) -_movdir64b (void *__dst, const void *__src) +_movdir64b (void *__dst __attribute__((align_value(64))), const void *__src) { __builtin_ia32_movdir64b(__dst, __src); } diff --git a/test/CodeGen/builtin-movdir.c b/test/CodeGen/builtin-movdir.c index 39f3fad997..c805a05184 100644 --- a/test/CodeGen/builtin-movdir.c +++ b/test/CodeGen/builtin-movdir.c @@ -1,5 +1,5 @@ // RUN: %clang_cc1 -ffreestanding -Wall -pedantic -triple x86_64-unknown-unknown -target-feature +movdiri -target-feature +movdir64b %s -emit-llvm -o - | FileCheck %s --check-prefix=X86_64 --check-prefix=CHECK -// RUN: %clang_cc1 -ffreestanding -Wall -pedantic -triple i386-unknown-unknown -target-feature +movdiri -target-feature +movdir64b %s -emit-llvm -o - | FileCheck %s --check-prefix=CHECK +// RUN: %clang_cc1 -ffreestanding -Wall -pedantic -triple i386-unknown-unknown -target-feature +movdiri -target-feature +movdir64b %s -emit-llvm -o - | FileCheck %s --check-prefix=X86 --check-prefix=CHECK #include #include @@ -22,6 +22,11 @@ void test_directstore64(void *dst, uint64_t value) { void test_dir64b(void *dst, const void *src) { // CHECK-LABEL: test_dir64b + // CHECK: [[PTRINT1:%.+]] = ptrtoint + // X86: [[MASKEDPTR1:%.+]] = and i32 [[PTRINT1]], 63 + // X86: [[MASKCOND1:%.+]] = icmp eq i32 [[MASKEDPTR1]], 0 + // X86_64: [[MASKEDPTR1:%.+]] = and i64 [[PTRINT1]], 63 + // X86_64: [[MASKCOND1:%.+]] = icmp eq i64 [[MASKEDPTR1]], 0 // CHECK: call void @llvm.x86.movdir64b _movdir64b(dst, src); } -- 2.50.1