imm.u == r.imm.u);
}
+bool
+fs_reg::is_zero() const
+{
+ if (file != IMM)
+ return false;
+
+ return type == BRW_REGISTER_TYPE_F ? imm.f == 0.0 : imm.i == 0;
+}
+
+bool
+fs_reg::is_one() const
+{
+ if (file != IMM)
+ return false;
+
+ return type == BRW_REGISTER_TYPE_F ? imm.f == 1.0 : imm.i == 1;
+}
+
int
fs_visitor::type_size(const struct glsl_type *type)
{
continue;
/* a * 1.0 = a */
- if (inst->src[1].type == BRW_REGISTER_TYPE_F &&
- inst->src[1].imm.f == 1.0) {
+ if (inst->src[1].is_one()) {
inst->opcode = BRW_OPCODE_MOV;
inst->src[1] = reg_undef;
progress = true;
}
/* a * 0.0 = 0.0 */
- if (inst->src[1].type == BRW_REGISTER_TYPE_F &&
- inst->src[1].imm.f == 0.0) {
+ if (inst->src[1].is_zero()) {
inst->opcode = BRW_OPCODE_MOV;
- inst->src[0] = fs_reg(0.0f);
+ inst->src[0] = inst->src[1];
inst->src[1] = reg_undef;
progress = true;
break;
continue;
/* a + 0.0 = a */
- if (inst->src[1].type == BRW_REGISTER_TYPE_F &&
- inst->src[1].imm.f == 0.0) {
+ if (inst->src[1].is_zero()) {
inst->opcode = BRW_OPCODE_MOV;
inst->src[1] = reg_undef;
progress = true;
fs_reg(class fs_visitor *v, const struct glsl_type *type);
bool equals(const fs_reg &r) const;
+ bool is_zero() const;
+ bool is_one() const;
/** Register file: ARF, GRF, MRF, IMM. */
enum register_file file;