Enable support for data-dependent if-else
agent-lee opened this issue · comments
Needed for catching corner cases regarding pathological values.
Repro specification:
float acc = 0.0f;
for (int i = 0; i < 4; i++) {
acc += a_in[i] * a_in[i];
}
for (int i = 0; i < 4; i++) {
if (acc == 0.0f) {
b_out[i] = 0.0f;
} else {
b_out[i] = a_in[i] / acc;
}
}
}```
Compilation aborts with:
Writing intermediate files to: compile-out
==: this match expander must be used inside match
in: (== acc 0.0)
context...:
do-raise-syntax-error
apply-transformer-in-context
apply-transformer52
dispatch-transformer41
for-loop
[repeats 1 more time]
finish-bodys
for-loop
finish-bodys
for-loop
[repeats 1 more time]
finish-bodys
for-loop
[repeats 1 more time]
finish-bodys
for-loop
...
Error: Compilation aborted. cdios return error code 1.
The example kernel here is data-dependent, so support will probably involve modifying the rewrite engine and backend in addition to the c frontend.