Patchwork GNU Superopt patches 4/6

login
register
mail settings
Submitter Joe Seymour
Date Sept. 7, 2010, 10:04 a.m.
Message ID <201009071004.o87A4jU8025777@brsbs01.icerasemi.com>
Download mbox | patch
Permalink /patch/63981/
State New
Headers show

Comments

Joe Seymour - Sept. 7, 2010, 10:04 a.m.
This one initializes first register to zero if R0_READS_ZERO is defined as 1:

Tues Aug 31 2010  Joseph Seymour  <Seymour@IceraSemi.com>

	* superopt.c (main_synth): Conditionally set first register to zero.
	(test_sequence): Conditionally set first register to zero.

Patch

diff -up ./superopt.c /home/seymour/tp/superopt-2.5/superopt.c
--- ./superopt.c	2010-08-27 17:01:19.000000000 +0100
+++ /home/seymour/tp/superopt-2.5/superopt.c	2010-09-01 11:08:44.338227000 +0100
@@ -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");