Consider the following loops:
int idx = ii; int max = mm; for (int i = 0; i < n; ++i) { int x = a[i]; if (max < x) { max = x; idx = i; } }
and
int idx = ii; int max = mm; for (int i = 0; i < n; ++i) { int x = a[i]; if (max <= x) { max = x; idx = i; } }
Changes:
- New recurrence kinds: SelectIVICmp and SelectIVFCmp. This is temporary. Eventually, SelectICmp/SelectFCmp should be able to fully support conditional scalar assignment. At that time, SelectIVICmp/SelectIVFCmp will be removed.
- New recurrence Kinds: MinMaxFirstIdx and MinMaxLastIdx. This kind is not directly generated by function AddReductionVar, but converted from SelectIVICmp/SelectIVFCmp.
TODOs:
- Now have not support that the min/max recurrence without exit instruction. Refer to test case smax_idx_max_no_exit_user.
- Support the min/max recurrence in select(cmp()). Refer to test case smax_idx_select_cmp.
- Support FP min/max recurrence.