| 1 |
// { dg-do run } |
| 2 |
|
| 3 |
// PR tree-optimization/105769 |
| 4 |
|
| 5 |
// The partitioning code would incorrectly have bias |
| 6 |
// and a temporary in the same partitioning because |
| 7 |
// it was thought bias was not alive when those were alive |
| 8 |
// do to vectorization of a store of pointers (that included bias). |
| 9 |
|
| 10 |
#include <functional> |
| 11 |
|
| 12 |
template<size_t n, class T> |
| 13 |
struct vec { |
| 14 |
T dat[n]; |
| 15 |
vec() {} |
| 16 |
explicit vec(const T& x) { for(size_t i = 0; i < n; i++) dat[i] = x; } |
| 17 |
T& operator [](size_t i) { return dat[i]; } |
| 18 |
const T& operator [](size_t i) const { return dat[i]; } |
| 19 |
}; |
| 20 |
|
| 21 |
template<size_t m, size_t n, class T> |
| 22 |
using mat = vec<m, vec<n, T>>; |
| 23 |
template<size_t n, class T> |
| 24 |
using sq_mat = mat<n, n, T>; |
| 25 |
using map_t = std::function<size_t(size_t)>; |
| 26 |
template<class T_v> |
| 27 |
using est_t = std::function<T_v(map_t map)>; |
| 28 |
template<class T_v> using est2_t = std::function<T_v(map_t map)>; |
| 29 |
map_t id_map() { return [](size_t j) -> size_t { return j; }; } |
| 30 |
|
| 31 |
template<size_t n, class T> |
| 32 |
est2_t<void> jacknife(const est_t<vec<n, T>> est, sq_mat<n, T>& cov, vec<n, T>& bias) { |
| 33 |
return [est, &cov, &bias](map_t map) -> void |
| 34 |
{ |
| 35 |
bias = est(map); |
| 36 |
for(size_t i = 0; i < n; i++) |
| 37 |
{ |
| 38 |
bias[i].print(); |
| 39 |
} |
| 40 |
}; |
| 41 |
} |
| 42 |
|
| 43 |
template<class T> |
| 44 |
void print_cov_ratio() { |
| 45 |
sq_mat<2, T> cov_jn; |
| 46 |
vec<2, T> bias; |
| 47 |
jacknife<2, T>([](map_t map) -> vec<2, T> { vec<2, T> retv; retv[0] = 1; retv[1] = 1; return retv; }, cov_jn, bias)(id_map()); |
| 48 |
} |
| 49 |
struct ab { |
| 50 |
long long unsigned a; |
| 51 |
short unsigned b; |
| 52 |
double operator()() { return a; } |
| 53 |
ab& operator=(double rhs) { a = rhs; return *this; } |
| 54 |
void print(); |
| 55 |
}; |
| 56 |
|
| 57 |
void |
| 58 |
ab::print() |
| 59 |
{ |
| 60 |
|
| 61 |
} |
| 62 |
|
| 63 |
int main() { |
| 64 |
print_cov_ratio<ab>(); |
| 65 |
return 0; |
| 66 |
} |
| 67 |
|