| 1 | // REQUIRES: hexagon-registered-target |
| 2 | // RUN: %clang_cc1 -emit-llvm -O2 -o - -triple hexagon-unknown-elf %s | FileCheck %s |
| 3 | // This unit test validates that the store to "dst" variable needs to be eliminated. |
| 4 | |
| 5 | // CHECK: @brev_store_elimination_test1 |
| 6 | // CHECK: llvm.hexagon.L2.loadri.pbr |
| 7 | // CHECK-NOT: store |
| 8 | |
| 9 | int *brev_store_elimination_test1(int *ptr, int mod) { |
| 10 | int dst = 100; |
| 11 | return __builtin_brev_ldw(ptr, &dst, mod); |
| 12 | } |
| 13 | |
| 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); |
| 22 | } |
| 23 | |
| 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); |
| 32 | } |
| 33 | return dst; |
| 34 | } |
| 35 | |
| 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); |
| 46 | } |
| 47 | |