aboutsummaryrefslogtreecommitdiffstats
path: root/src/intel/compiler/brw_vec4_nir.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/intel/compiler/brw_vec4_nir.cpp')
-rw-r--r--src/intel/compiler/brw_vec4_nir.cpp66
1 files changed, 15 insertions, 51 deletions
diff --git a/src/intel/compiler/brw_vec4_nir.cpp b/src/intel/compiler/brw_vec4_nir.cpp
index 561d7169d4c..0e65dd2b607 100644
--- a/src/intel/compiler/brw_vec4_nir.cpp
+++ b/src/intel/compiler/brw_vec4_nir.cpp
@@ -805,8 +805,6 @@ vec4_visitor::optimize_predicate(nir_alu_instr *instr,
unsigned base_swizzle =
brw_swizzle_for_nir_swizzle(cmp_instr->src[i].swizzle);
op[i].swizzle = brw_compose_swizzle(size_swizzle, base_swizzle);
- op[i].abs = cmp_instr->src[i].abs;
- op[i].negate = cmp_instr->src[i].negate;
}
emit(CMP(dst_null_d(), op[0], op[1],
@@ -864,8 +862,7 @@ emit_find_msb_using_lzd(const vec4_builder &bld,
}
void
-vec4_visitor::emit_conversion_from_double(dst_reg dst, src_reg src,
- bool saturate)
+vec4_visitor::emit_conversion_from_double(dst_reg dst, src_reg src)
{
/* BDW PRM vol 15 - workarounds:
* DF->f format conversion for Align16 has wrong emask calculation when
@@ -873,8 +870,7 @@ vec4_visitor::emit_conversion_from_double(dst_reg dst, src_reg src,
*/
if (devinfo->gen == 8 && dst.type == BRW_REGISTER_TYPE_F &&
src.file == BRW_IMMEDIATE_VALUE) {
- vec4_instruction *inst = emit(MOV(dst, brw_imm_f(src.df)));
- inst->saturate = saturate;
+ emit(MOV(dst, brw_imm_f(src.df)));
return;
}
@@ -899,20 +895,17 @@ vec4_visitor::emit_conversion_from_double(dst_reg dst, src_reg src,
emit(op, temp2, src_reg(temp));
emit(VEC4_OPCODE_PICK_LOW_32BIT, retype(temp2, dst.type), src_reg(temp2));
- vec4_instruction *inst = emit(MOV(dst, src_reg(retype(temp2, dst.type))));
- inst->saturate = saturate;
+ emit(MOV(dst, src_reg(retype(temp2, dst.type))));
}
void
-vec4_visitor::emit_conversion_to_double(dst_reg dst, src_reg src,
- bool saturate)
+vec4_visitor::emit_conversion_to_double(dst_reg dst, src_reg src)
{
dst_reg tmp_dst = dst_reg(src_reg(this, glsl_type::dvec4_type));
src_reg tmp_src = retype(src_reg(this, glsl_type::vec4_type), src.type);
emit(MOV(dst_reg(tmp_src), src));
emit(VEC4_OPCODE_TO_DOUBLE, tmp_dst, tmp_src);
- vec4_instruction *inst = emit(MOV(dst, src_reg(tmp_dst)));
- inst->saturate = saturate;
+ emit(MOV(dst, src_reg(tmp_dst)));
}
/**
@@ -1133,22 +1126,25 @@ vec4_visitor::nir_emit_alu(nir_alu_instr *instr)
dst_reg dst = get_nir_dest(instr->dest.dest, dst_type);
dst.writemask = instr->dest.write_mask;
+ assert(!instr->dest.saturate);
+
src_reg op[4];
for (unsigned i = 0; i < nir_op_infos[instr->op].num_inputs; i++) {
+ /* We don't lower to source modifiers, so they shouldn't exist. */
+ assert(!instr->src[i].abs);
+ assert(!instr->src[i].negate);
+
nir_alu_type src_type = (nir_alu_type)
(nir_op_infos[instr->op].input_types[i] |
nir_src_bit_size(instr->src[i].src));
op[i] = get_nir_src(instr->src[i].src, src_type, 4);
op[i].swizzle = brw_swizzle_for_nir_swizzle(instr->src[i].swizzle);
- op[i].abs = instr->src[i].abs;
- op[i].negate = instr->src[i].negate;
}
switch (instr->op) {
case nir_op_mov:
try_immediate_source(instr, &op[0], true, devinfo);
inst = emit(MOV(dst, op[0]));
- inst->saturate = instr->dest.saturate;
break;
case nir_op_vec2:
@@ -1159,14 +1155,13 @@ vec4_visitor::nir_emit_alu(nir_alu_instr *instr)
case nir_op_i2f32:
case nir_op_u2f32:
inst = emit(MOV(dst, op[0]));
- inst->saturate = instr->dest.saturate;
break;
case nir_op_f2f32:
case nir_op_f2i32:
case nir_op_f2u32:
if (nir_src_bit_size(instr->src[0].src) == 64)
- emit_conversion_from_double(dst, op[0], instr->dest.saturate);
+ emit_conversion_from_double(dst, op[0]);
else
inst = emit(MOV(dst, op[0]));
break;
@@ -1174,7 +1169,7 @@ vec4_visitor::nir_emit_alu(nir_alu_instr *instr)
case nir_op_f2f64:
case nir_op_i2f64:
case nir_op_u2f64:
- emit_conversion_to_double(dst, op[0], instr->dest.saturate);
+ emit_conversion_to_double(dst, op[0]);
break;
case nir_op_fsat:
@@ -1186,8 +1181,6 @@ vec4_visitor::nir_emit_alu(nir_alu_instr *instr)
case nir_op_ineg:
op[0].negate = true;
inst = emit(MOV(dst, op[0]));
- if (instr->op == nir_op_fneg)
- inst->saturate = instr->dest.saturate;
break;
case nir_op_fabs:
@@ -1195,8 +1188,6 @@ vec4_visitor::nir_emit_alu(nir_alu_instr *instr)
op[0].negate = false;
op[0].abs = true;
inst = emit(MOV(dst, op[0]));
- if (instr->op == nir_op_fabs)
- inst->saturate = instr->dest.saturate;
break;
case nir_op_iadd:
@@ -1205,7 +1196,6 @@ vec4_visitor::nir_emit_alu(nir_alu_instr *instr)
case nir_op_fadd:
try_immediate_source(instr, op, true, devinfo);
inst = emit(ADD(dst, op[0], op[1]));
- inst->saturate = instr->dest.saturate;
break;
case nir_op_uadd_sat:
@@ -1217,7 +1207,6 @@ vec4_visitor::nir_emit_alu(nir_alu_instr *instr)
case nir_op_fmul:
try_immediate_source(instr, op, true, devinfo);
inst = emit(MUL(dst, op[0], op[1]));
- inst->saturate = instr->dest.saturate;
break;
case nir_op_imul: {
@@ -1272,27 +1261,22 @@ vec4_visitor::nir_emit_alu(nir_alu_instr *instr)
case nir_op_frcp:
inst = emit_math(SHADER_OPCODE_RCP, dst, op[0]);
- inst->saturate = instr->dest.saturate;
break;
case nir_op_fexp2:
inst = emit_math(SHADER_OPCODE_EXP2, dst, op[0]);
- inst->saturate = instr->dest.saturate;
break;
case nir_op_flog2:
inst = emit_math(SHADER_OPCODE_LOG2, dst, op[0]);
- inst->saturate = instr->dest.saturate;
break;
case nir_op_fsin:
inst = emit_math(SHADER_OPCODE_SIN, dst, op[0]);
- inst->saturate = instr->dest.saturate;
break;
case nir_op_fcos:
inst = emit_math(SHADER_OPCODE_COS, dst, op[0]);
- inst->saturate = instr->dest.saturate;
break;
case nir_op_idiv:
@@ -1347,17 +1331,14 @@ vec4_visitor::nir_emit_alu(nir_alu_instr *instr)
case nir_op_fsqrt:
inst = emit_math(SHADER_OPCODE_SQRT, dst, op[0]);
- inst->saturate = instr->dest.saturate;
break;
case nir_op_frsq:
inst = emit_math(SHADER_OPCODE_RSQ, dst, op[0]);
- inst->saturate = instr->dest.saturate;
break;
case nir_op_fpow:
inst = emit_math(SHADER_OPCODE_POW, dst, op[0], op[1]);
- inst->saturate = instr->dest.saturate;
break;
case nir_op_uadd_carry: {
@@ -1386,7 +1367,6 @@ vec4_visitor::nir_emit_alu(nir_alu_instr *instr)
inst->predicate = BRW_PREDICATE_NORMAL;
inst = emit(MOV(dst, src_reg(dst))); /* for potential saturation */
}
- inst->saturate = instr->dest.saturate;
break;
case nir_op_fceil: {
@@ -1400,18 +1380,15 @@ vec4_visitor::nir_emit_alu(nir_alu_instr *instr)
emit(RNDD(dst_reg(tmp), op[0]));
tmp.negate = true;
inst = emit(MOV(dst, tmp));
- inst->saturate = instr->dest.saturate;
break;
}
case nir_op_ffloor:
inst = emit(RNDD(dst, op[0]));
- inst->saturate = instr->dest.saturate;
break;
case nir_op_ffract:
inst = emit(FRC(dst, op[0]));
- inst->saturate = instr->dest.saturate;
break;
case nir_op_fround_even:
@@ -1422,7 +1399,6 @@ vec4_visitor::nir_emit_alu(nir_alu_instr *instr)
inst->predicate = BRW_PREDICATE_NORMAL;
inst = emit(MOV(dst, src_reg(dst))); /* for potential saturation */
}
- inst->saturate = instr->dest.saturate;
break;
case nir_op_fquantize2f16: {
@@ -1446,7 +1422,6 @@ vec4_visitor::nir_emit_alu(nir_alu_instr *instr)
/* Select that or zero based on normal status */
inst = emit(BRW_OPCODE_SEL, dst, zero, tmp32);
inst->predicate = BRW_PREDICATE_NORMAL;
- inst->saturate = instr->dest.saturate;
break;
}
@@ -1457,7 +1432,6 @@ vec4_visitor::nir_emit_alu(nir_alu_instr *instr)
case nir_op_fmin:
try_immediate_source(instr, op, true, devinfo);
inst = emit_minmax(BRW_CONDITIONAL_L, dst, op[0], op[1]);
- inst->saturate = instr->dest.saturate;
break;
case nir_op_imax:
@@ -1467,7 +1441,6 @@ vec4_visitor::nir_emit_alu(nir_alu_instr *instr)
case nir_op_fmax:
try_immediate_source(instr, op, true, devinfo);
inst = emit_minmax(BRW_CONDITIONAL_GE, dst, op[0], op[1]);
- inst->saturate = instr->dest.saturate;
break;
case nir_op_fddx:
@@ -1598,7 +1571,7 @@ vec4_visitor::nir_emit_alu(nir_alu_instr *instr)
case nir_op_b2f64:
if (nir_dest_bit_size(instr->dest.dest) > 32) {
assert(dst.type == BRW_REGISTER_TYPE_DF);
- emit_conversion_to_double(dst, negate(op[0]), false);
+ emit_conversion_to_double(dst, negate(op[0]));
} else {
emit(MOV(dst, negate(op[0])));
}
@@ -1815,7 +1788,6 @@ vec4_visitor::nir_emit_alu(nir_alu_instr *instr)
unreachable("not reached: should have been lowered");
case nir_op_fsign:
- assert(!instr->dest.saturate);
if (op[0].abs) {
/* Straightforward since the source can be assumed to be either
* strictly >= 0 or strictly <= 0 depending on the setting of the
@@ -1874,8 +1846,7 @@ vec4_visitor::nir_emit_alu(nir_alu_instr *instr)
/* Now convert the result from float to double */
emit_conversion_to_double(dst, retype(src_reg(tmp),
- BRW_REGISTER_TYPE_F),
- false);
+ BRW_REGISTER_TYPE_F));
}
break;
@@ -1902,18 +1873,15 @@ vec4_visitor::nir_emit_alu(nir_alu_instr *instr)
dst_reg mul_dst = dst_reg(this, glsl_type::dvec4_type);
emit(MUL(mul_dst, op[1], op[0]));
inst = emit(ADD(dst, src_reg(mul_dst), op[2]));
- inst->saturate = instr->dest.saturate;
} else {
fix_float_operands(op, instr);
inst = emit(MAD(dst, op[2], op[1], op[0]));
- inst->saturate = instr->dest.saturate;
}
break;
case nir_op_flrp:
fix_float_operands(op, instr);
inst = emit(LRP(dst, op[2], op[1], op[0]));
- inst->saturate = instr->dest.saturate;
break;
case nir_op_b32csel:
@@ -1945,25 +1913,21 @@ vec4_visitor::nir_emit_alu(nir_alu_instr *instr)
case nir_op_fdot_replicated2:
try_immediate_source(instr, op, true, devinfo);
inst = emit(BRW_OPCODE_DP2, dst, op[0], op[1]);
- inst->saturate = instr->dest.saturate;
break;
case nir_op_fdot_replicated3:
try_immediate_source(instr, op, true, devinfo);
inst = emit(BRW_OPCODE_DP3, dst, op[0], op[1]);
- inst->saturate = instr->dest.saturate;
break;
case nir_op_fdot_replicated4:
try_immediate_source(instr, op, true, devinfo);
inst = emit(BRW_OPCODE_DP4, dst, op[0], op[1]);
- inst->saturate = instr->dest.saturate;
break;
case nir_op_fdph_replicated:
try_immediate_source(instr, op, false, devinfo);
inst = emit(BRW_OPCODE_DPH, dst, op[0], op[1]);
- inst->saturate = instr->dest.saturate;
break;
case nir_op_fdiv: