From 18f69890d1992d6777d9a73e628a0e348bb117a5 Mon Sep 17 00:00:00 2001 From: Job Noorman Date: Fri, 10 Oct 2025 07:30:18 +0200 Subject: [PATCH] nir: add nir_shr builder Sometimes we need to select between ishr/ushr based some condition; this builder makes this less verbose. Signed-off-by: Job Noorman Reviewed-by: Alyssa Rosenzweig Part-of: --- src/compiler/nir/nir_builder.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/compiler/nir/nir_builder.h b/src/compiler/nir/nir_builder.h index c59e962e8dd..fa203839adb 100644 --- a/src/compiler/nir/nir_builder.h +++ b/src/compiler/nir/nir_builder.h @@ -1213,6 +1213,12 @@ nir_ushr_imm(nir_builder *build, nir_def *x, uint32_t y) } } +static inline nir_def * +nir_shr(nir_builder *build, bool is_signed, nir_def *x, nir_def *y) +{ + return is_signed ? nir_ishr(build, x, y) : nir_ushr(build, x, y); +} + static inline nir_def * nir_imod_imm(nir_builder *build, nir_def *x, uint64_t y) {