Decompose Mul(x, 2**b + 2**a) into y = x + x << (b - a), y << a instead of y = x...
authorChristoph Mallon <christoph.mallon@gmx.de>
Tue, 16 Oct 2007 20:57:43 +0000 (20:57 +0000)
committerChristoph Mallon <christoph.mallon@gmx.de>
Tue, 16 Oct 2007 20:57:43 +0000 (20:57 +0000)
[r16240]

ir/ir/irarch.c

index 051512a..17c8f41 100644 (file)
@@ -326,11 +326,16 @@ static instruction *decompose_simple_cases(mul_env *env, unsigned char *R, int r
                assert(r == 2);
 
                ins = env->root;
+               if (R[1] <= env->max_S) {
+                       ins = emit_LEA(env, ins, ins, R[1]);
+                       if (R[0] != 0) {
+                               ins = emit_SHIFT(env, ins, R[0]);
+                       }
+                       return ins;
+               }
                if (R[0] != 0) {
                        ins = emit_SHIFT(env, ins, R[0]);
                }
-               if (R[1] <= env->max_S)
-                       return emit_LEA(env, ins, ins, R[1]);
 
                ins2 = emit_SHIFT(env, env->root, R[0] + R[1]);
                return emit_LEA(env, ins, ins2, 0);