@@ -2543,9 +2543,16 @@ test_sequence(insn_t *sequence, int n_in
{
/* Update the tvalues array in each iteration, as execution of the
sequence might clobber the values. (On 2-operand machines.) */
- for (i = arity - 1; i >= 0; i--)
+#if R0_READS_0
+ /* If the first register always reads zero, set it and place
+ arguments starting from second register. */
+ tvalues[0] = 0;
+ for (i = arity; i > 0; i--) {
+#else
+ for (i = arity-1; i >= 0; i--) {
+#endif
tvalues[i] = *test_set++;
-
+ }
/* Execute the synthesised sequence for the current operand
values. */
#if HAS_NULLIFICATION
@@ -2751,11 +2758,24 @@ main_synth(int min_cost, int maxmax_cost
/* Don't pass CY_JUST_SET ever, since we don't know which of the
predefined insn above set cy. */
+#if R0_READS_0
+ /* If first register reads zero set it, and make sure synth
+ know's it starts with arity + 1 live registers. Also ensure
+ that eval_goal_function, gets it's args correctly (indexed
+ from zero). */
+ values[0] = 0;
+ SYNTH(sequence, ii, values, goal_function_arity+ii+1,
+ (*eval_goal_function)(values+1),
+ max_cost, i, NO_PRUNE
+ , NOT_NULLIFY
+ );
+#else
SYNTH(sequence, ii, values, goal_function_arity+ii,
(*eval_goal_function)(values),
max_cost, i, NO_PRUNE
, NOT_NULLIFY
);
+#endif
#ifdef STATISTICS
printf("\n");