intel/compiler: Make the CMPN builder work like the CMP builder

Since the CMPN builder was never used, there was no reason to make its
interface usable. :)

Fixes: 2f2c00c727 ("i965: Lower min/max after optimization on Gen4/5.")
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9027>
(cherry picked from commit 684ec33c79)
This commit is contained in:
Ian Romanick 2021-02-13 13:22:41 -08:00 committed by Dylan Baker
parent 674a536825
commit 56a31d5210
3 changed files with 51 additions and 3 deletions

View file

@ -355,7 +355,7 @@
"description": "intel/compiler: Make the CMPN builder work like the CMP builder",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"master_sha": null,
"because_sha": "2f2c00c7279e7c43e520e21de1781f8cec263e92"
},

View file

@ -565,7 +565,6 @@ namespace brw {
ALU3(BFI2)
ALU1(BFREV)
ALU1(CBIT)
ALU2(CMPN)
ALU1(DIM)
ALU2(DP2)
ALU2(DP3)
@ -633,6 +632,31 @@ namespace brw {
fix_unsigned_negate(src1)));
}
/**
* CMPN: Behaves like CMP, but produces true if src1 is NaN.
*/
instruction *
CMPN(const dst_reg &dst, const src_reg &src0, const src_reg &src1,
brw_conditional_mod condition) const
{
/* Take the instruction:
*
* CMP null<d> src0<f> src1<f>
*
* Original gen4 does type conversion to the destination type
* before comparison, producing garbage results for floating
* point comparisons.
*
* The destination type doesn't matter on newer generations,
* so we set the type to match src0 so we can compact the
* instruction.
*/
return set_condmod(condition,
emit(BRW_OPCODE_CMPN, retype(dst, src0.type),
fix_unsigned_negate(src0),
fix_unsigned_negate(src1)));
}
/**
* Gen4 predicated IF.
*/

View file

@ -403,7 +403,6 @@ namespace brw {
ALU3(BFI2)
ALU1(BFREV)
ALU1(CBIT)
ALU2(CMPN)
ALU3(CSEL)
ALU1(DIM)
ALU2(DP2)
@ -470,6 +469,31 @@ namespace brw {
fix_unsigned_negate(src1)));
}
/**
* CMPN: Behaves like CMP, but produces true if src1 is NaN.
*/
instruction *
CMPN(const dst_reg &dst, const src_reg &src0, const src_reg &src1,
brw_conditional_mod condition) const
{
/* Take the instruction:
*
* CMPN null<d> src0<f> src1<f>
*
* Original gen4 does type conversion to the destination type
* before comparison, producing garbage results for floating
* point comparisons.
*
* The destination type doesn't matter on newer generations,
* so we set the type to match src0 so we can compact the
* instruction.
*/
return set_condmod(condition,
emit(BRW_OPCODE_CMPN, retype(dst, src0.type),
fix_unsigned_negate(src0),
fix_unsigned_negate(src1)));
}
/**
* Gen4 predicated IF.
*/