No, because it's not allowed to replace
/* NBEANS = 257 */
int sales[NSHOPS][NBEANS];
int sales_internal[NSHOPS][260];
because 260 can be efficiently backcracked while 257 can't.
We will leave it up to the language lawyers for a ruling on whether or
not the compiler is allowed to make this change (I think not, but am not
sure). But I don't think any compiler /would/ make that change, even if
it turns out to be legal.
However, no one is asking a compiler to do this change - changing a
multiply by 257 into a multiply by 260 would change the logic of the
code. I am saying that you should let the compiler change the multiply
by 257 into shifts-and-adds if it wants, you should never do it manually.
Once you've worked out that 260 can be backcracked, 257 can't be, you can
write C code with 260 hardcoded.
I am close to giving up and killfiling you for my own sanity.
"backcrack" is clearly yet another of your private terms that you think
are known to all speakers of the English language. I had assumed you
were talking about the ease of transforming multiplies into
shifts-and-adds, since that was what you were talking about a few posts
earlier when you incorrectly claimed that it might be worth converting
"y * 260 + x" into "((y << 8) | (y << 2)) + x". As I pointed out
earlier, this is an incorrect transformation (unless you are sure that y
is less than 64 and non-negative). The correct transformation would be
"(y << 8) + (y << 2) + x". And any half-decent compiler will do such
strength reduction as and when appropriate.
/If/ that is what you mean by "backcrack", then y * 257 + x can also be
"backcracked" into (y << 8) + y + x. This is simpler, and could be
faster than the shift+add arrangement for 260.
But then you've got to look at the assembly
to check that the compiler genuinely made the optimisation.
If you care about the speed here, your main task is to measure the
timings. /How/ the compiler optimises the code is secondary to how fast
the code is (compared to how fast you need it to be). Looking at the
assembly is one way to get an idea if you don't want to measure the real
times - it should not be hard in this particular case.
Also, there
are lots of numbers you could potentially pad to. Unless you've got some insight
into the instruction set, it's hard to know which ones to choose. The average
person is not going to think "260, that's only got two set bits".
The average person is not going to care - they will let the compiler
deal with it. The more advanced programmer will know that 257 /also/
has only two bits set, and the bit numbers are more amenable to optimal
speed even on the simplest of processors. And a /really/ advanced
programmer will take a step back and think whether this matters, and if
so ask what the /real/ bottlenecks are - aligning to cache lines is
likely to be more relevant than the multiplication on big systems.