From: Jason Ekstrand Date: Sat, 29 Aug 2020 05:59:22 +0000 (-0500) Subject: nir: Add a load_global_constant intrinsic X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ff124e3fe3e89c594b91e62d3e233cfc2af3ef34;p=mesa.git nir: Add a load_global_constant intrinsic This has the same semantics as load_global except the memory it reads is known to be constant so load_global_constant intrinsics can be CSEd rather than relying on more complex copy-propagation. Reviewed-by: Karol Herbst Part-of: --- diff --git a/src/compiler/nir/nir_divergence_analysis.c b/src/compiler/nir/nir_divergence_analysis.c index 05892b440bf..85663c83615 100644 --- a/src/compiler/nir/nir_divergence_analysis.c +++ b/src/compiler/nir/nir_divergence_analysis.c @@ -255,6 +255,7 @@ visit_intrinsic(nir_intrinsic_instr *instr, struct divergence_state *state) case nir_intrinsic_load_ssbo: case nir_intrinsic_load_shared: case nir_intrinsic_load_global: + case nir_intrinsic_load_global_constant: case nir_intrinsic_load_uniform: case nir_intrinsic_load_push_constant: case nir_intrinsic_load_constant: diff --git a/src/compiler/nir/nir_intrinsics.py b/src/compiler/nir/nir_intrinsics.py index 73a5bce6a27..2ef14a56984 100644 --- a/src/compiler/nir/nir_intrinsics.py +++ b/src/compiler/nir/nir_intrinsics.py @@ -768,6 +768,9 @@ load("constant", [1], [BASE, RANGE, ALIGN_MUL, ALIGN_OFFSET], # src[] = { address }. load("global", [1], [ACCESS, ALIGN_MUL, ALIGN_OFFSET], [CAN_ELIMINATE]) # src[] = { address }. +load("global_constant", [1], [ACCESS, ALIGN_MUL, ALIGN_OFFSET], + [CAN_ELIMINATE, CAN_REORDER]) +# src[] = { address }. load("kernel_input", [1], [BASE, RANGE, ALIGN_MUL, ALIGN_OFFSET], [CAN_ELIMINATE, CAN_REORDER]) # src[] = { offset }. load("scratch", [1], [ALIGN_MUL, ALIGN_OFFSET], [CAN_ELIMINATE]) diff --git a/src/compiler/nir/nir_lower_io.c b/src/compiler/nir/nir_lower_io.c index 9250a7ec1bb..1dc2a2d1bfd 100644 --- a/src/compiler/nir/nir_lower_io.c +++ b/src/compiler/nir/nir_lower_io.c @@ -1632,6 +1632,7 @@ nir_get_io_offset_src(nir_intrinsic_instr *instr) case nir_intrinsic_load_shared: case nir_intrinsic_load_uniform: case nir_intrinsic_load_global: + case nir_intrinsic_load_global_constant: case nir_intrinsic_load_scratch: case nir_intrinsic_load_fs_input_interp_deltas: case nir_intrinsic_shared_atomic_add: diff --git a/src/compiler/nir/nir_lower_phis_to_scalar.c b/src/compiler/nir/nir_lower_phis_to_scalar.c index 9389c8f787b..2e3cdfffc37 100644 --- a/src/compiler/nir/nir_lower_phis_to_scalar.c +++ b/src/compiler/nir/nir_lower_phis_to_scalar.c @@ -103,6 +103,7 @@ is_phi_src_scalarizable(nir_phi_src *src, case nir_intrinsic_load_ubo: case nir_intrinsic_load_ssbo: case nir_intrinsic_load_global: + case nir_intrinsic_load_global_constant: case nir_intrinsic_load_input: return true; default: diff --git a/src/compiler/nir/nir_opt_gcm.c b/src/compiler/nir/nir_opt_gcm.c index 02aced6b45c..6129eacd079 100644 --- a/src/compiler/nir/nir_opt_gcm.c +++ b/src/compiler/nir/nir_opt_gcm.c @@ -157,6 +157,7 @@ is_src_scalarizable(nir_src *src) case nir_intrinsic_load_ubo: case nir_intrinsic_load_ssbo: case nir_intrinsic_load_global: + case nir_intrinsic_load_global_constant: case nir_intrinsic_load_input: return true; default: diff --git a/src/compiler/nir/nir_opt_shrink_vectors.c b/src/compiler/nir/nir_opt_shrink_vectors.c index 0790138a749..d46b377f0ac 100644 --- a/src/compiler/nir/nir_opt_shrink_vectors.c +++ b/src/compiler/nir/nir_opt_shrink_vectors.c @@ -123,6 +123,7 @@ opt_shrink_vectors_intrinsic(nir_builder *b, nir_intrinsic_instr *instr) case nir_intrinsic_load_push_constant: case nir_intrinsic_load_constant: case nir_intrinsic_load_global: + case nir_intrinsic_load_global_constant: case nir_intrinsic_load_kernel_input: case nir_intrinsic_load_scratch: case nir_intrinsic_store_output: diff --git a/src/compiler/nir/nir_validate.c b/src/compiler/nir/nir_validate.c index 9d2dfbc8206..11e9841e178 100644 --- a/src/compiler/nir/nir_validate.c +++ b/src/compiler/nir/nir_validate.c @@ -598,6 +598,7 @@ validate_intrinsic_instr(nir_intrinsic_instr *instr, validate_state *state) case nir_intrinsic_load_ssbo: case nir_intrinsic_load_shared: case nir_intrinsic_load_global: + case nir_intrinsic_load_global_constant: case nir_intrinsic_load_scratch: case nir_intrinsic_load_constant: /* These memory load operations must have alignments */