Mesa (master): nir/lower_idiv: Use ilt instead of bit twiddling
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Sun Dec 16 21:03:23 UTC 2018
Module: Mesa
Branch: master
Commit: e17426058cd50d8302acd5155846871a2f39b408
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e17426058cd50d8302acd5155846871a2f39b408
Author: Jason Ekstrand <jason.ekstrand at intel.com>
Date: Sun Dec 16 00:42:01 2018 -0600
nir/lower_idiv: Use ilt instead of bit twiddling
The previous code was creating a boolean by doing an arithmetic right-
shift by 31 which produces a boolean which is true if the argument is
negative. This is the same as the expression r < 0 which is much
simpler and doesn't depend on NIR's representation of booleans.
Reviewed-by: Eric Anholt <eric at anholt.net>
---
src/compiler/nir/nir_lower_idiv.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/compiler/nir/nir_lower_idiv.c b/src/compiler/nir/nir_lower_idiv.c
index b2a0a3c189..4e7e2408ae 100644
--- a/src/compiler/nir/nir_lower_idiv.c
+++ b/src/compiler/nir/nir_lower_idiv.c
@@ -101,7 +101,7 @@ convert_instr(nir_builder *bld, nir_alu_instr *alu)
if (is_signed) {
/* fix the sign: */
r = nir_ixor(bld, numer, denom);
- r = nir_ishr(bld, r, nir_imm_int(bld, 31));
+ r = nir_ilt(bld, r, nir_imm_int(bld, 0));
b = nir_ineg(bld, q);
q = nir_bcsel(bld, r, b, q);
}
More information about the mesa-commit
mailing list