Hi !
An expression is treated as constant if it
a) is deterministic, so it gives same results every time evaluated with same parameters
b) does not have parameters from tables
Apparently stored function are considered by mysql as non-deterministic and you have changed it. I agree with Jakub - while it works in your case the change is not fully safe in the sense that one can write a non-deterministic function, which would be considered as a deterministic one.
ICE examines the parameter list (on the query level - which columns are used as the input parameters) and it sees there are no parameters.
The combination of the two above give the observed speedup. Good work on the code!