"Matt Lee" <reachmatt.lee@xxxxxxxxx> writes: > Here is what I have, > > case AND: > case IOR: > case XOR: > *total = COSTS_N_INSNS (1); > return true; > case ASHIFT: > case ASHIFTRT: > case LSHIFTRT: > if (GET_CODE (XEXP (x, 1)) == CONST_INT) > *total = COSTS_N_INSNS (INTVAL (XEXP (x, 1))); > return true; > > > This looks quite OK to me. I tried debugging if rtx_costs was doing > something wrong. I do see rtx_cost being invoked for the lshiftrt > expressions in question, but never for the "and". Seems like GCC had > pre-decided to only use lshiftrt even though it is expensive. Your computations look wrong to me. You are saying that an AND always costs 1 instruction. But you need to actually look at the operands. Specifically, the compiler is going to compare these two: (and (reg ...) (const_int ...) (and (ashiftrt (reg ...) (const_int ...)) (const_int 1)) > Any other ideas? Btw, I couldn't find prefer_and_bit_test in dojump.c. I'm looking at the current version of gcc. prefer_and_bit_test was added 2004-03-20, so I guess that just missed 3.4. I don't have 3.4 sources handy. In general the decision is made in the do_jump function. Ian