lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I am more curious, why does Lua not optimize 1==1.

Thank you.

Hugo Musso Gualandi <hgualandi@inf.puc-rio.br> 于2021年8月2日周一 上午1:07写道:

Both the f and the g are being optimized in those examples. Note how
the f function uses the LOADK instruction instead of GETUPVAL.

The `local a <const> = 1` in your original program is also optimized,
transforming the `a == 1` into `1 == 1`. However, Lua doesn't optimize
the `1 == 1` as you would expect. That's a separate problem that is
unrelated to the constant variables.