Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CodeGen / PowerPC / builtins-ppc-xlcompat-LoadReseve-StoreCond.c
blobe05e35fa98b74462c2f3ea9a8a641bc37fe4dc2e
1 // REQUIRES: powerpc-registered-target
2 // RUN: %clang_cc1 -O2 -target-cpu pwr8 -triple=powerpc-unknown-aix \
3 // RUN: -emit-llvm %s -o - | FileCheck %s
4 // RUN: %clang_cc1 -O2 -target-cpu pwr8 -triple=powerpc64-unknown-aix \
5 // RUN: -emit-llvm %s -o - | FileCheck %s
6 // RUN: %clang_cc1 -O2 -target-cpu pwr8 -triple=powerpc64le-unknown-linux-gnu \
7 // RUN: -emit-llvm %s -o - | FileCheck %s
8 // RUN: %clang_cc1 -O2 -target-cpu pwr8 -triple=powerpc64-unknown-linux-gnu \
9 // RUN: -emit-llvm %s -o - | FileCheck %s
10 // RAUN: not %clang_cc1 -O2 -target-cpu pwr7 -triple=powerpc-unknown-aix \
11 // RAUN: -emit-llvm %s -o - 2>&1 | FileCheck %s \
12 // RAUN: --check-prefix=CHECK-NON-PWR8-ERR
14 int test_lwarx(volatile int* a) {
15 // CHECK-LABEL: @test_lwarx
16 // CHECK: %0 = tail call i32 asm sideeffect "lwarx $0, ${1:y}", "=r,*Z,~{memory}"(ptr elementtype(i32) %a)
17 return __lwarx(a);
20 short test_lharx(volatile short *a) {
21 // CHECK-LABEL: @test_lharx
22 // CHECK: %0 = tail call i16 asm sideeffect "lharx $0, ${1:y}", "=r,*Z,~{memory}"(ptr elementtype(i16) %a)
23 // CHECK-NON-PWR8-ERR: error: this builtin is only valid on POWER8 or later CPUs
24 return __lharx(a);
27 char test_lbarx(volatile char *a) {
28 // CHECK-LABEL: @test_lbarx
29 // CHECK: %0 = tail call i8 asm sideeffect "lbarx $0, ${1:y}", "=r,*Z,~{memory}"(ptr elementtype(i8) %a)
30 // CHECK-NON-PWR8-ERR: error: this builtin is only valid on POWER8 or later CPUs
31 return __lbarx(a);
34 int test_stwcx(volatile int* a, int val) {
35 // CHECK-LABEL: @test_stwcx
36 // CHECK: %0 = tail call i32 @llvm.ppc.stwcx(ptr %a, i32 %val)
37 return __stwcx(a, val);
40 int test_sthcx(volatile short *a, short val) {
41 // CHECK-LABEL: @test_sthcx
42 // CHECK: %0 = sext i16 %val to i32
43 // CHECK: %1 = tail call i32 @llvm.ppc.sthcx(ptr %a, i32 %0)
44 // CHECK-NON-PWR8-ERR: error: this builtin is only valid on POWER8 or later CPUs
45 return __sthcx(a, val);
48 // Extra test cases that previously caused error during usage.
49 int test_lharx_intret(volatile short *a) {
50 // CHECK-LABEL: @test_lharx_intret
51 // CHECK: %0 = tail call i16 asm sideeffect "lharx $0, ${1:y}", "=r,*Z,~{memory}"(ptr elementtype(i16) %a)
52 // CHECK-NON-PWR8-ERR: error: this builtin is only valid on POWER8 or later CPUs
53 return __lharx(a);
56 int test_lbarx_intret(volatile char *a) {
57 // CHECK-LABEL: @test_lbarx_intret
58 // CHECK: %0 = tail call i8 asm sideeffect "lbarx $0, ${1:y}", "=r,*Z,~{memory}"(ptr elementtype(i8) %a)
59 // CHECK-NON-PWR8-ERR: error: this builtin is only valid on POWER8 or later CPUs
60 return __lbarx(a);