63 lines · cpp
1// Test frontend handling of nontemporal builtins.2// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm %s -o - | FileCheck %s3 4signed char sc;5unsigned char uc;6signed short ss;7unsigned short us;8signed int si;9unsigned int ui;10signed long long sll;11unsigned long long ull;12float f1, f2;13double d1, d2;14float __attribute__((vector_size(16))) vf1, vf2;15char __attribute__((vector_size(8))) vc1, vc2;16bool b1, b2;17 18void test_all_sizes(void) // CHECK-LABEL: test_all_sizes19{20 __builtin_nontemporal_store(true, &b1); // CHECK: store i8 1, ptr @b1, align 1, !nontemporal21 __builtin_nontemporal_store(b1, &b2); // CHECK: store i8{{.*}}, align 1, !nontemporal22 __builtin_nontemporal_store(1, &uc); // CHECK: store i8{{.*}}align 1, !nontemporal23 __builtin_nontemporal_store(1, &sc); // CHECK: store i8{{.*}}align 1, !nontemporal24 __builtin_nontemporal_store(1, &us); // CHECK: store i16{{.*}}align 2, !nontemporal25 __builtin_nontemporal_store(1, &ss); // CHECK: store i16{{.*}}align 2, !nontemporal26 __builtin_nontemporal_store(1, &ui); // CHECK: store i32{{.*}}align 4, !nontemporal27 __builtin_nontemporal_store(1, &si); // CHECK: store i32{{.*}}align 4, !nontemporal28 __builtin_nontemporal_store(1, &ull); // CHECK: store i64{{.*}}align 8, !nontemporal29 __builtin_nontemporal_store(1, &sll); // CHECK: store i64{{.*}}align 8, !nontemporal30 __builtin_nontemporal_store(1.0, &f1); // CHECK: store float{{.*}}align 4, !nontemporal31 __builtin_nontemporal_store(1.0, &d1); // CHECK: store double{{.*}}align 8, !nontemporal32 __builtin_nontemporal_store(vf1, &vf2); // CHECK: store <4 x float>{{.*}}align 16, !nontemporal33 __builtin_nontemporal_store(vc1, &vc2); // CHECK: store <8 x i8>{{.*}}align 8, !nontemporal34 35 b1 = __builtin_nontemporal_load(&b2); // CHECK: load i8{{.*}}align 1, !nontemporal36 uc = __builtin_nontemporal_load(&sc); // CHECK: load i8{{.*}}align 1, !nontemporal37 sc = __builtin_nontemporal_load(&uc); // CHECK: load i8{{.*}}align 1, !nontemporal38 us = __builtin_nontemporal_load(&ss); // CHECK: load i16{{.*}}align 2, !nontemporal39 ss = __builtin_nontemporal_load(&us); // CHECK: load i16{{.*}}align 2, !nontemporal40 ui = __builtin_nontemporal_load(&si); // CHECK: load i32{{.*}}align 4, !nontemporal41 si = __builtin_nontemporal_load(&ui); // CHECK: load i32{{.*}}align 4, !nontemporal42 ull = __builtin_nontemporal_load(&sll); // CHECK: load i64{{.*}}align 8, !nontemporal43 sll = __builtin_nontemporal_load(&ull); // CHECK: load i64{{.*}}align 8, !nontemporal44 f1 = __builtin_nontemporal_load(&f2); // CHECK: load float{{.*}}align 4, !nontemporal45 d1 = __builtin_nontemporal_load(&d2); // CHECK: load double{{.*}}align 8, !nontemporal46 vf2 = __builtin_nontemporal_load(&vf1); // CHECK: load <4 x float>{{.*}}align 16, !nontemporal47 vc2 = __builtin_nontemporal_load(&vc1); // CHECK: load <8 x i8>{{.*}}align 8, !nontemporal48}49 50struct S { char c[16]; };51S x;52 53typedef int v4si __attribute__ ((vector_size(16)));54 55// CHECK-LABEL: define void @_Z14test_alignmentv()56// CHECK: load <4 x i32>, ptr @x, align 1, !nontemporal57// CHECK: store <4 x i32> %1, ptr @x, align 1, !nontemporal58 59void test_alignment() {60 auto t = __builtin_nontemporal_load((v4si*)x.c);61 __builtin_nontemporal_store(t, (v4si*)x.c);62}63