Re: [Mesa-dev] [PATCH 53/59] intel/compiler: implement is_zero, is_one, is_negative_one for 8-bit/16-bit
On Fri, 2018-12-07 at 14:25 -0600, Jason Ekstrand wrote: > On Tue, Dec 4, 2018 at 1:18 AM Iago Toral Quiroga > wrote: > > There are no 8-bit immediates, so assert in that case. > > > > 16-bit immediates are replicated in each word of a 32-bit > > immediate, so > > > > we only need to check the lower 16-bits. > > > > --- > > > > src/intel/compiler/brw_shader.cpp | 20 > > > > 1 file changed, 20 insertions(+) > > > > > > > > diff --git a/src/intel/compiler/brw_shader.cpp > > b/src/intel/compiler/brw_shader.cpp > > > > index b77bd798d17..adbb52f 100644 > > > > --- a/src/intel/compiler/brw_shader.cpp > > > > +++ b/src/intel/compiler/brw_shader.cpp > > > > @@ -708,11 +708,18 @@ backend_reg::is_zero() const > > > > if (file != IMM) > > > >return false; > > > > > > > > + assert(type_sz(type) > 1); > > > > + > > We should probably also assert that things are properly replicated. Good idea, I'll add that too. > > > switch (type) { > > > > + case BRW_REGISTER_TYPE_HF: > > > > + return (d & 0x) == 0; > > Do we want to check for -0 as well? I think that'd be 0x8000. Mmm... yes, I think we should probably do that. Thanks! > > case BRW_REGISTER_TYPE_F: > > > >return f == 0; > > > > case BRW_REGISTER_TYPE_DF: > > > >return df == 0; > > > > + case BRW_REGISTER_TYPE_W: > > > > + case BRW_REGISTER_TYPE_UW: > > > > + return (d & 0x) == 0; > > > > case BRW_REGISTER_TYPE_D: > > > > case BRW_REGISTER_TYPE_UD: > > > >return d == 0; > > > > @@ -730,11 +737,18 @@ backend_reg::is_one() const > > > > if (file != IMM) > > > >return false; > > > > > > > > + assert(type_sz(type) > 1); > > Again, assert proper replication? > > + > > > > switch (type) { > > > > + case BRW_REGISTER_TYPE_HF: > > > > + return (d & 0x) == 0x3c00; > > > > case BRW_REGISTER_TYPE_F: > > > >return f == 1.0f; > > > > case BRW_REGISTER_TYPE_DF: > > > >return df == 1.0; > > > > + case BRW_REGISTER_TYPE_W: > > > > + case BRW_REGISTER_TYPE_UW: > > > > + return (d & 0x) == 1; > > > > case BRW_REGISTER_TYPE_D: > > > > case BRW_REGISTER_TYPE_UD: > > > >return d == 1; > > > > @@ -752,11 +766,17 @@ backend_reg::is_negative_one() const > > > > if (file != IMM) > > > >return false; > > > > > > > > + assert(type_sz(type) > 1); > > > > + > > > > switch (type) { > > > > + case BRW_REGISTER_TYPE_HF: > > > > + return (d & 0x) == 0xbc00; > > > > case BRW_REGISTER_TYPE_F: > > > >return f == -1.0; > > > > case BRW_REGISTER_TYPE_DF: > > > >return df == -1.0; > > > > + case BRW_REGISTER_TYPE_W: > > > > + return (d & 0x) == -1; > > > > case BRW_REGISTER_TYPE_D: > > > >return d == -1; > > > > case BRW_REGISTER_TYPE_Q: > > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 53/59] intel/compiler: implement is_zero, is_one, is_negative_one for 8-bit/16-bit
On Tue, Dec 4, 2018 at 1:18 AM Iago Toral Quiroga wrote: > There are no 8-bit immediates, so assert in that case. > 16-bit immediates are replicated in each word of a 32-bit immediate, so > we only need to check the lower 16-bits. > --- > src/intel/compiler/brw_shader.cpp | 20 > 1 file changed, 20 insertions(+) > > diff --git a/src/intel/compiler/brw_shader.cpp > b/src/intel/compiler/brw_shader.cpp > index b77bd798d17..adbb52f 100644 > --- a/src/intel/compiler/brw_shader.cpp > +++ b/src/intel/compiler/brw_shader.cpp > @@ -708,11 +708,18 @@ backend_reg::is_zero() const > if (file != IMM) >return false; > > + assert(type_sz(type) > 1); > + > We should probably also assert that things are properly replicated. > switch (type) { > + case BRW_REGISTER_TYPE_HF: > + return (d & 0x) == 0; > Do we want to check for -0 as well? I think that'd be 0x8000. > case BRW_REGISTER_TYPE_F: >return f == 0; > case BRW_REGISTER_TYPE_DF: >return df == 0; > + case BRW_REGISTER_TYPE_W: > + case BRW_REGISTER_TYPE_UW: > + return (d & 0x) == 0; > case BRW_REGISTER_TYPE_D: > case BRW_REGISTER_TYPE_UD: >return d == 0; > @@ -730,11 +737,18 @@ backend_reg::is_one() const > if (file != IMM) >return false; > > + assert(type_sz(type) > 1); > Again, assert proper replication? > + > switch (type) { > + case BRW_REGISTER_TYPE_HF: > + return (d & 0x) == 0x3c00; > case BRW_REGISTER_TYPE_F: >return f == 1.0f; > case BRW_REGISTER_TYPE_DF: >return df == 1.0; > + case BRW_REGISTER_TYPE_W: > + case BRW_REGISTER_TYPE_UW: > + return (d & 0x) == 1; > case BRW_REGISTER_TYPE_D: > case BRW_REGISTER_TYPE_UD: >return d == 1; > @@ -752,11 +766,17 @@ backend_reg::is_negative_one() const > if (file != IMM) >return false; > > + assert(type_sz(type) > 1); > + > switch (type) { > + case BRW_REGISTER_TYPE_HF: > + return (d & 0x) == 0xbc00; > case BRW_REGISTER_TYPE_F: >return f == -1.0; > case BRW_REGISTER_TYPE_DF: >return df == -1.0; > + case BRW_REGISTER_TYPE_W: > + return (d & 0x) == -1; > case BRW_REGISTER_TYPE_D: >return d == -1; > case BRW_REGISTER_TYPE_Q: > -- > 2.17.1 > > ___ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/mesa-dev > ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 53/59] intel/compiler: implement is_zero, is_one, is_negative_one for 8-bit/16-bit
There are no 8-bit immediates, so assert in that case. 16-bit immediates are replicated in each word of a 32-bit immediate, so we only need to check the lower 16-bits. --- src/intel/compiler/brw_shader.cpp | 20 1 file changed, 20 insertions(+) diff --git a/src/intel/compiler/brw_shader.cpp b/src/intel/compiler/brw_shader.cpp index b77bd798d17..adbb52f 100644 --- a/src/intel/compiler/brw_shader.cpp +++ b/src/intel/compiler/brw_shader.cpp @@ -708,11 +708,18 @@ backend_reg::is_zero() const if (file != IMM) return false; + assert(type_sz(type) > 1); + switch (type) { + case BRW_REGISTER_TYPE_HF: + return (d & 0x) == 0; case BRW_REGISTER_TYPE_F: return f == 0; case BRW_REGISTER_TYPE_DF: return df == 0; + case BRW_REGISTER_TYPE_W: + case BRW_REGISTER_TYPE_UW: + return (d & 0x) == 0; case BRW_REGISTER_TYPE_D: case BRW_REGISTER_TYPE_UD: return d == 0; @@ -730,11 +737,18 @@ backend_reg::is_one() const if (file != IMM) return false; + assert(type_sz(type) > 1); + switch (type) { + case BRW_REGISTER_TYPE_HF: + return (d & 0x) == 0x3c00; case BRW_REGISTER_TYPE_F: return f == 1.0f; case BRW_REGISTER_TYPE_DF: return df == 1.0; + case BRW_REGISTER_TYPE_W: + case BRW_REGISTER_TYPE_UW: + return (d & 0x) == 1; case BRW_REGISTER_TYPE_D: case BRW_REGISTER_TYPE_UD: return d == 1; @@ -752,11 +766,17 @@ backend_reg::is_negative_one() const if (file != IMM) return false; + assert(type_sz(type) > 1); + switch (type) { + case BRW_REGISTER_TYPE_HF: + return (d & 0x) == 0xbc00; case BRW_REGISTER_TYPE_F: return f == -1.0; case BRW_REGISTER_TYPE_DF: return df == -1.0; + case BRW_REGISTER_TYPE_W: + return (d & 0x) == -1; case BRW_REGISTER_TYPE_D: return d == -1; case BRW_REGISTER_TYPE_Q: -- 2.17.1 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev