diff -up /home/seymour/tp/superopt-2.5/superopt.c ./superopt.c
--- /home/seymour/tp/superopt-2.5/superopt.c	2010-09-01 12:07:53.000698000 +0100
+++ ./superopt.c	2010-09-01 11:52:10.000000000 +0100
@@ -43,6 +43,7 @@ int flag_result_lim = 0;
 unsigned int n_reassure_after = 4000000000UL;
 unsigned int cycle_count      = 4000000000UL;
 unsigned int reassure_count = 0;
+int flag_consts = 0;
 
 /* Counts the number of solutions found.  Flags to top loop that it should
    not go deeper.  */
@@ -97,8 +98,8 @@ void
 init_immediates(word *values)
 {
   int i;
-  for (i = -1; i < BITS_PER_WORD; i++)
-    values[0x20 + i] = i;
+  for (i = MIN_IMMEDIATE; i <= MAX_UNSIGNED_IMMEDIATE; i++)
+    values[0x20 + (-1 * MIN_IMMEDIATE) + i] = i;
 
   values[0x20 - 2] = VALUE_MIN_SIGNED;
   values[0x20 - 3] = VALUE_MAX_SIGNED;
@@ -415,7 +416,7 @@ recurse_last(opcode_t opcode,
 #endif
 }
 
-#define NAME(op) operand_names[op]
+#define NAME(op) (op > 0x20) ? operand_names[op - N_IMMEDIATES] : operand_names[op]
 static char *operand_names[256]=
 {
 #if SPARC
@@ -2395,7 +2396,30 @@ output_assembly(insn_t insn)
   printf("\n");
 }
 
-word tvalues[0x100];
+word tvalues[0x20 + (int) (N_IMMEDIATES * 1.5 ) + 1];
+word consts[((int) (N_IMMEDIATES * 1.5)) + 1];
+int n_const = 0;
+
+/* Built in sets of immediate values, enabled by command line flags */
+#define POT(X) (1 << X)
+#define POTMO(X) ((POT (X)) - 1)
+word cpot[]   = {POT (1), POT (2), POT (3), POT (4), POT (5), POT (6), POT (7),
+                 POT(8), POT (9), POT (11), POT (12), POT (13), POT (14),
+                 POT (15), POT (16), POT (17), POT (18), POT (19), POT (20)};
+word cpotmo[] = {POTMO (1), POTMO (2), POTMO (3), POTMO (4), POTMO (5),
+                 POTMO (6), POTMO (7), POTMO(8), POTMO (9), POTMO (11),
+                 POTMO (12), POTMO (13), POTMO (14), POTMO (15), POTMO (16),
+                 POTMO (17), POTMO (18), POTMO (19), POTMO (20)};
+
+/* Append all elements of v, to a, starting at index i.
+   Ensuring memory overflow doesn't occour is left to the caller */
+#define ARRAY_ADD(a,i,v) \
+  {                                                     \
+    int j;                                              \
+    for ( j = 0; j < (sizeof(v)/sizeof(word)); j++ ) {  \
+      a[i++] =  v[j];                                    \
+    }                                                   \
+  }
 
 /* TEST_SETS contains sets of input values and corresponding goal value used
    to test the correctness of a sequence.  N_TEST_SETS says how many sets
@@ -2693,7 +2717,7 @@ void
 main_synth(int min_cost, int maxmax_cost, int allowed_extra_cost)
 {
   int max_cost;
-  word values[0x100];
+  word values[0x20 + (int) (N_IMMEDIATES * 1.5) + 1];
   insn_t sequence[0x100];
   int i, ii;
 
@@ -2702,6 +2726,17 @@ main_synth(int min_cost, int maxmax_cost
   init_random_word();
   init_test_sets();
 
+  consts[n_const++] = -1;
+  consts[n_const++] = 0;
+  consts[n_const++] = 1;
+
+  if (flag_consts)
+    {
+      for (i = MIN_IMMEDIATE; i <= MAX_UNSIGNED_IMMEDIATE; i++)
+        consts[(-1 * MIN_IMMEDIATE) + i] = i;
+    }
+  n_const = i;
+
   /* Speed hack: Try to find random values that makes the goal function
      take a value != 0.  Many false sequences give 0 for all input,
      and this hack achieve quick rejection of these sequences.  */
@@ -2918,6 +2953,32 @@ main(int argc, char **argv)
 	flag_shifts = 1;
       else if (!strncmp(arg, "-extracts", arglen))
 	flag_extracts = 1;
+      else if (!strncmp(arg, "-consts", arglen))
+        flag_consts = 1;
+      else if (!strncmp(arg, "-cpotmo", arglen)) {
+        ARRAY_ADD(consts,n_const,cpotmo);
+      }
+      else if (!strncmp(arg, "-cpot", arglen)) {
+        ARRAY_ADD(consts,n_const,cpot);
+      }
+      else if (!strncmp(arg, "-clist", arglen)) {
+            argv++;
+            argc--;
+            if (argc == 0)
+              {
+                fprintf(stderr, "superoptimizer: argument to `-clist' expected\n");
+                exit(-1);
+              }
+          while (argc > 0 && atoi(*argv) != 0) {
+            consts[n_const++] = atoi(*argv);
+            argv++;
+            argc--;
+          }
+          if ( argc >= 0 ) {
+            argv--;
+            argc++;
+          }
+      }
       else if (!strncmp(arg, "-limit", arglen))
 	{
 	  argv++;
@@ -2990,6 +3051,8 @@ main(int argc, char **argv)
 	  char *prefix;
 	  fprintf(stderr, "Calling sequence:\n\n");
 	  fprintf(stderr, "\t%s -f<goal-function> [-assembly] [-max-cost n] [-min-cost n]\\\n", program);
+          fprintf(stderr, "\t\t[-consts] [-clist <n>...]");
+          fprintf(stderr, " [-cpot] [-cpotmo]\n");
 	  fprintf(stderr, "\t\t[-no-carry-insns] [-extra-cost n] [-nl]\n\n");
 	  fprintf(stderr, "Target machine: %s\n\n", TARGET_STRING);
 	  fprintf(stderr, "Supported goal functions:\n\n");
diff -up /home/seymour/tp/superopt-2.5/superopt.h ./superopt.h
--- /home/seymour/tp/superopt-2.5/superopt.h	2010-09-01 12:07:45.079238000 +0100
+++ ./superopt.h	2010-09-01 11:52:10.000000000 +0100
@@ -177,8 +177,16 @@ typedef unsigned_word word;
 #define VALUE_MIN_SIGNED ((word) 1 << (BITS_PER_WORD - 1))
 #define VALUE_MAX_SIGNED (((word) 1 << (BITS_PER_WORD - 1)) - 1)
 
-#define CNST(n) (0x20 + n)
-#define VALUE(n) n
+#ifndef IMMEDIATE_SIZE
+#define IMMEDIATE_SIZE 11
+#endif
+#define MIN_IMMEDIATE (~(1 << (IMMEDIATE_SIZE - 1)) + 1)
+#define MAX_SIGNED_IMMEDIATE (((1 << (IMMEDIATE_SIZE - 1)) - 1))
+#define MAX_UNSIGNED_IMMEDIATE (1 << IMMEDIATE_SIZE)
+#define N_IMMEDIATES (1 << IMMEDIATE_SIZE)
+
+#define CNST(n) (0x20 + N_IMMEDIATES + n)
+#define VALUE(n) (n)
 
 /* The IMMEDIATE_* macros are for printing assembly.  NOT for sequence
    generating or analyze.  */
@@ -191,7 +199,7 @@ static const word __immediate_val[] =
   0xff
 };
 #define IMMEDIATE_VAL(op) \
-  ((op) >= 0x20 - 1 ? op - 0x20 : __immediate_val[0x20 - 2 - (op)])
+  (op - N_IMMEDIATES - 0x20)
 
 typedef enum
 {
@@ -208,9 +216,9 @@ typedef enum
 typedef struct
 {
   opcode_t opcode:11;
-  unsigned int s1:7;
-  unsigned int s2:7;
-  unsigned int d:7;
+  unsigned int s1;
+  unsigned int s2;
+  unsigned int d;
 } insn_t;
 
 #if __GNUC__ < 2
