+/**
+ * Optimize x / c to x * (1/c)
+ */
+static ir_node *transform_node_Quot(ir_node *n) {
+ ir_mode *mode = get_Quot_resmode(n);
+ ir_node *oldn = n;
+
+ if (get_mode_arithmetic(mode) == irma_ieee754) {
+ ir_node *b = get_Quot_right(n);
+
+ if (is_Const(b)) {
+ tarval *tv = get_Const_tarval(b);
+
+ tv = tarval_quo(get_mode_one(mode), tv);
+
+ /* Do the transformation if the result is either exact or we are not
+ using strict rules. */
+ if (tv != tarval_bad &&
+ (tarval_ieee754_get_exact() || (get_irg_fp_model(current_ir_graph) & fp_strict_algebraic) == 0)) {
+ ir_node *blk = get_irn_n(n, -1);
+ ir_node *c = new_r_Const(current_ir_graph, blk, mode, tv);
+ ir_node *a = get_Quot_left(n);
+ ir_node *m = new_rd_Mul(get_irn_dbg_info(n), current_ir_graph, blk, a, c, mode);
+ ir_node *mem = get_Quot_mem(n);
+
+ /* skip a potential Pin */
+ if (is_Pin(mem))
+ mem = get_Pin_op(mem);
+ turn_into_tuple(n, pn_Quot_max);
+ set_Tuple_pred(n, pn_Quot_M, mem);
+ set_Tuple_pred(n, pn_Quot_X_regular, new_r_Jmp(current_ir_graph, blk));
+ set_Tuple_pred(n, pn_Quot_X_except, new_r_Bad(current_ir_graph));
+ set_Tuple_pred(n, pn_Quot_res, m);
+ DBG_OPT_ALGSIM1(oldn, a, b, m, FS_OPT_FP_INV_MUL);
+ }
+ }
+ }
+ return n;
+} /* transform_node_Quot */
+