* the result.
*/
-static bool
-is_not_zero(enum ssa_ranges r)
-{
- return r == gt_zero || r == lt_zero || r == ne_zero;
-}
-
static void *
pack_data(const struct ssa_result_range r)
{
ASSERT_TABLE_IS_COMMUTATIVE(fadd_table);
ASSERT_TABLE_IS_DIAGONAL(fadd_table);
- /* ge_zero: ge_zero * ge_zero
+ /* Due to flush-to-zero semanatics of floating-point numbers with very
+ * small mangnitudes, we can never really be sure a result will be
+ * non-zero.
+ *
+ * ge_zero: ge_zero * ge_zero
* | ge_zero * gt_zero
* | ge_zero * eq_zero
* | le_zero * lt_zero
* | gt_zero * ge_zero # Multiplication is commutative
* | eq_zero * ge_zero # Multiplication is commutative
* | a * a # Left source == right source
- * ;
- *
- * gt_zero: gt_zero * gt_zero
+ * | gt_zero * gt_zero
* | lt_zero * lt_zero
* ;
*
* | lt_zero * ge_zero # Multiplication is commutative
* | le_zero * ge_zero # Multiplication is commutative
* | le_zero * gt_zero
- * ;
- *
- * lt_zero: lt_zero * gt_zero
+ * | lt_zero * gt_zero
* | gt_zero * lt_zero # Multiplication is commutative
* ;
*
- * ne_zero: ne_zero * gt_zero
- * | ne_zero * lt_zero
- * | gt_zero * ne_zero # Multiplication is commutative
- * | lt_zero * ne_zero # Multiplication is commutative
- * | ne_zero * ne_zero
- * ;
- *
* eq_zero: eq_zero * <any>
* <any> * eq_zero # Multiplication is commutative
*
static const enum ssa_ranges fmul_table[last_range + 1][last_range + 1] = {
/* left\right unknown lt_zero le_zero gt_zero ge_zero ne_zero eq_zero */
/* unknown */ { _______, _______, _______, _______, _______, _______, eq_zero },
- /* lt_zero */ { _______, gt_zero, ge_zero, lt_zero, le_zero, ne_zero, eq_zero },
+ /* lt_zero */ { _______, ge_zero, ge_zero, le_zero, le_zero, _______, eq_zero },
/* le_zero */ { _______, ge_zero, ge_zero, le_zero, le_zero, _______, eq_zero },
- /* gt_zero */ { _______, lt_zero, le_zero, gt_zero, ge_zero, ne_zero, eq_zero },
+ /* gt_zero */ { _______, le_zero, le_zero, ge_zero, ge_zero, _______, eq_zero },
/* ge_zero */ { _______, le_zero, le_zero, ge_zero, ge_zero, _______, eq_zero },
- /* ne_zero */ { _______, ne_zero, _______, ne_zero, _______, ne_zero, eq_zero },
+ /* ne_zero */ { _______, _______, _______, _______, _______, _______, eq_zero },
/* eq_zero */ { eq_zero, eq_zero, eq_zero, eq_zero, eq_zero, eq_zero, eq_zero }
};
/* x * x => ge_zero */
if (left.range != eq_zero && nir_alu_srcs_equal(alu, alu, 0, 1)) {
- /* x * x => ge_zero or gt_zero depending on the range of x. */
- r.range = is_not_zero(left.range) ? gt_zero : ge_zero;
+ /* Even if x > 0, the result of x*x can be zero when x is, for
+ * example, a subnormal number.
+ */
+ r.range = ge_zero;
} else if (left.range != eq_zero && nir_alu_srcs_negative_equal(alu, alu, 0, 1)) {
- /* -x * x => le_zero or lt_zero depending on the range of x. */
- r.range = is_not_zero(left.range) ? lt_zero : le_zero;
+ /* -x * x => le_zero. */
+ r.range = le_zero;
} else
r.range = fmul_table[left.range][right.range];
enum ssa_ranges fmul_range;
if (first.range != eq_zero && nir_alu_srcs_equal(alu, alu, 0, 1)) {
- /* x * x => ge_zero or gt_zero depending on the range of x. */
- fmul_range = is_not_zero(first.range) ? gt_zero : ge_zero;
+ /* See handling of nir_op_fmul for explanation of why ge_zero is the
+ * range.
+ */
+ fmul_range = ge_zero;
} else if (first.range != eq_zero && nir_alu_srcs_negative_equal(alu, alu, 0, 1)) {
- /* -x * x => le_zero or lt_zero depending on the range of x. */
- fmul_range = is_not_zero(first.range) ? lt_zero : le_zero;
+ /* -x * x => le_zero */
+ fmul_range = le_zero;
} else
fmul_range = fmul_table[first.range][second.range];