Commit 3cb4edfe authored by Paul's avatar Paul
Browse files

Try to fix ice on gcc 5

parent 8c8e5fb0
......@@ -190,10 +190,21 @@ auto pop_back_args(Ts&&... xs)
};
}
template<class T>
struct always_f
{
T x;
template<class... Ts>
constexpr T operator()(Ts&&...) const
{
return x;
}
};
template <class T>
auto always(T x)
{
return [=](auto&&...) { return x; };
return always_f<T>{x};
}
} // namespace MIGRAPHX_INLINE_NS
......
......@@ -261,14 +261,21 @@ struct lazy_or
template <class Op, bool Start, bool Matches>
struct folder
{
template<class... Ms>
static bool fold_match(matcher_context& ctx, instruction_ref ins, Ms... ms)
{
Op op;
auto matched = [&](auto m) { return [&] { return ctx.matched(m, ins); }; };
return
fold([&](auto x, auto y) { return op(always(x), matched(y)); })(Start, ms...);
}
template <class... Ts>
auto operator()(Ts... ms) const
{
return make_bf_matcher([=](matcher_context& ctx, instruction_ref ins) {
Op op;
auto matched = [&](auto m) { return [&] { return ctx.matched(m, ins); }; };
bool matches =
fold([&](auto x, auto y) { return op(always(x), matched(y)); })(Start, ms...);
bool matches = folder::fold_match(ctx, ins, ms...);
if(matches == Matches)
return ins;
return ctx.not_found();
......@@ -283,12 +290,8 @@ struct folder
Op op;
bool matches = Start;
select(start, [&](auto ins) {
auto matched = [&](auto m) { return [&] { return ctx.matched(m, ins); }; };
auto fold_match = [&] {
return fold([&](auto x, auto y) { return op(always(x), matched(y)); })(
Start, ms...);
};
matches = op(always(matches), fold_match);
auto fm = [&] { return folder::fold_match(ctx, ins, ms...); };
matches = op(always(matches), fm);
});
if(matches == Matches)
return start;
......
......@@ -148,6 +148,20 @@ TEST_CASE(match_arg7)
EXPECT(bool{r.result == sum});
}
TEST_CASE(match_arg8)
{
migraphx::program p;
auto one = p.add_literal(1);
auto two = p.add_literal(2);
auto sum = p.add_instruction(sum_op{}, one, two);
p.add_instruction(pass_op{}, sum);
auto m = match::name("sum")(match::all_of(match::arg(0)(match::name("@literal")),
match::arg(1)(match::name("@literal"))),
match::standard_shape());
auto r = find_match(p, m);
EXPECT(bool{r.result == sum});
}
TEST_CASE(match_args1)
{
migraphx::program p;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment