If a function is inside the same compilation unit as the caller, the compiler can often output some facts about it - for example, that its output cannot change for subsequent calls. In general, however, this is not so.
In your example, assigning variables to these simple arithmetic expressions does not change anything with respect to the generated object code and, in my opinion, makes the code less readable. If you do not have a bunch of long expressions that cannot reasonably be placed in one or two lines, you should avoid using temporary variables - if not for any other reason, then simply to reduce pollution of the namespace.
The use of temporary variables implies significant administrator overhead for the programmer to keep them separate and avoid unintended side effects. It also simplifies the reuse of code snippets.
On the other hand, assigning the result of a function to a variable can help the compiler optimize your code better by explicitly avoiding multiple function calls.
Personally, I would go with this:
int expr = someObject->someFunction(); for (int i = (a - 1) * b; i < a * b && i < expr; i++) {
thkala
source share