Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CodeGen / hexagon-brev-store-elm.c
blobd5fc187411819559293912f3d0fb304cdb6ab70c
1 // REQUIRES: hexagon-registered-target
2 // RUN: %clang_cc1 -emit-llvm -O2 -o - -triple hexagon-unknown-elf -target-cpu hexagonv60 %s | FileCheck %s
3 // This unit test validates that the store to "dst" variable needs to be eliminated.
5 // CHECK: @brev_store_elimination_test1
6 // CHECK: llvm.hexagon.L2.loadri.pbr
7 // CHECK-NOT: store
9 int *brev_store_elimination_test1(int *ptr, int mod) {
10 int dst = 100;
11 return __builtin_brev_ldw(ptr, &dst, mod);
14 // CHECK: @brev_store_elimination_test2
15 // CHECK: llvm.hexagon.L2.loadri.pbr
16 // CHECK-NOT: store
17 extern int add(int a);
18 int brev_store_elimination_test2(int *ptr, int mod) {
19 int dst = 100;
20 __builtin_brev_ldw(ptr, &dst, mod);
21 return add(dst);
24 // CHECK: @brev_store_elimination_test3
25 // CHECK: llvm.hexagon.L2.loadri.pbr
26 // CHECK-NOT: store
27 int brev_store_elimination_test3(int *ptr, int mod, int inc) {
28 int dst = 100;
29 for (int i = 0; i < inc; ++i) {
30 __builtin_brev_ldw(ptr, &dst, mod);
31 dst = add(dst);
33 return dst;
36 // brev_store_elimination_test4 validates the fact that we are not deleting the
37 // stores if the value is passed by reference later.
38 // CHECK: @brev_store_elimination_test4
39 // CHECK: llvm.hexagon.L2.loadri.pbr
40 // CHECK: store
41 extern int sub(int *a);
42 int brev_store_elimination_test4(int *ptr, int mod) {
43 int dst = 100;
44 __builtin_brev_ldw(ptr, &dst, mod);
45 return sub(&dst);