Open
Description
Lookup tables are quite common, as in https://golang.org/src/math/bits/bits_tables.go. However none of functions that rely on those tables can be constant folded.
Simplest example is https://go.godbolt.org/z/MhMTqb which compiles to:
movblzx math/bits.rev8tab+12(SB), AX
movb AL, "".~r0+8(SP)
The rev8tab
only contains indexing to that table, so it should be possible to prove that the array is not being modified. Of course that only holds, when assignment, slicing or addressing operator is not used.
If such table is replaced with a string, then the constant folding does work. However, that seems like an ugly hack to have.
Related Issues: