nir/constant_folding: fold load_constant intrinsics

These can appear after loop unrolling.

v2: stylistic changes
v2: replace state->mem_ctx with state->shader
v2: add bounds checking
v3: use nir_intrinsic_range() for bounds checking
v3: fix issue where partially out-of-bounds reads are replaced with undefs
v4: fix merge conflicts during rebase

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
38 jobs for !1893 with nir_load_constant_opt in 33 minutes and 42 seconds (queued for 6 seconds)
detached
Status Job ID Name Coverage
  Containers
passed #621166
debian

00:00:22

passed #621167
aarch64
test-container:arm64

00:00:19

 
  Build
passed #621170
meson-arm64

00:04:28

passed #621169
meson-armhf

00:02:14

passed #621172
meson-clang

00:08:35

passed #621175
meson-clover

00:09:14

passed #621177
meson-i386

00:02:54

passed #621168
meson-main

00:09:33

passed #621171
meson-swr-glvnd

00:05:19

passed #621176
meson-vulkan

00:02:01

passed #621179
scons-llvm

00:06:10

passed #621178
scons-nollvm

00:02:57

passed #621173
scons-swr

00:05:55

passed #621174
scons-win64

00:05:18

 
  Test
passed #621200
db410c
arm64_a306_gles2 1/4

00:08:37

passed #621201
db410c
arm64_a306_gles2 2/4

00:10:30

passed #621202
db410c
arm64_a306_gles2 3/4

00:04:08

passed #621203
db410c
arm64_a306_gles2 4/4

00:04:26

passed #621189
mesa-cheza
arm64_a630_gles2

00:04:29

passed #621190
mesa-cheza
arm64_a630_gles31 1/4

00:06:43

passed #621191
mesa-cheza
arm64_a630_gles31 2/4

00:07:54

passed #621192
mesa-cheza
arm64_a630_gles31 3/4

00:07:53

passed #621193
mesa-cheza
arm64_a630_gles31 4/4

00:07:25

passed #621194
mesa-cheza
arm64_a630_gles3 1/6

00:04:59

passed #621195
mesa-cheza
arm64_a630_gles3 2/6

00:04:31

passed #621196
mesa-cheza
arm64_a630_gles3 3/6

00:04:20

passed #621197
mesa-cheza
arm64_a630_gles3 4/6

00:04:39

passed #621198
mesa-cheza
arm64_a630_gles3 5/6

00:04:20

passed #621199
mesa-cheza
arm64_a630_gles3 6/6

00:04:13

passed #621180
test-llvmpipe-gles2 1/4

00:03:35

passed #621181
test-llvmpipe-gles2 2/4

00:03:42

passed #621182
test-llvmpipe-gles2 3/4

00:03:37

passed #621183
test-llvmpipe-gles2 4/4

00:04:00

passed #621184
test-softpipe-gles2 1/4

00:01:02

passed #621185
test-softpipe-gles2 2/4

00:01:36

passed #621186
test-softpipe-gles2 3/4

00:01:23

passed #621187
test-softpipe-gles2 4/4

00:01:27

passed #621188
test-softpipe-gles3-limited

00:03:54