return (ir == NULL) ? false : ir->is_value(2.0, 2);
}
+static inline bool
+is_vec_four(ir_constant *ir)
+{
+ return (ir == NULL) ? false : ir->is_value(4.0, 4);
+}
+
static inline bool
is_vec_negative_one(ir_constant *ir)
{
continue;
ir_expression *add_expr = floor_expr->operands[0]->as_expression();
- if (!add_expr)
+ if (!add_expr || add_expr->operation != ir_binop_add)
continue;
for (int j = 0; j < 2; j++) {
continue;
ir_constant *point_five = add_expr->operands[1 - j]->as_constant();
- if (!point_five->is_value(0.5, 0))
+ if (!point_five || !point_five->is_value(0.5, 0))
continue;
if (abs_expr->operands[0]->equals(sign_expr->operands[0])) {
return mul(x, x);
}
+ if (is_vec_four(op_const[1])) {
+ ir_variable *x = new(ir) ir_variable(ir->operands[1]->type, "x",
+ ir_var_temporary);
+ base_ir->insert_before(x);
+ base_ir->insert_before(assign(x, ir->operands[0]));
+
+ ir_variable *squared = new(ir) ir_variable(ir->operands[1]->type,
+ "squared",
+ ir_var_temporary);
+ base_ir->insert_before(squared);
+ base_ir->insert_before(assign(squared, mul(x, x)));
+ return mul(squared, squared);
+ }
+
break;
case ir_binop_min: