/*
- * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved.
+ * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
*
* This file is part of libFirm.
*
* Calculate the gain when using the generalized complementary technique
*/
static int calculate_gain(unsigned char *R, int r) {
- int max_gain = -1;
- int idx, i;
+ int max_gain = 0;
+ int idx = -1, i;
int gain;
/* the gain for r == 1 */
idx = i;
}
}
- if (max_gain > 0)
- return idx;
- return -1;
+ return idx;
}
/**
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);