"Amker.Cheng" <amker.ch...@gmail.com> writes: > HI: > There is comment on lui_movf in mips.md like following, > > ;; because we don't split it. FIXME: we should split instead. > > I can split it into a move and a condmove(movesi_on_cc) insns , like > > (define_split > [(set (match_operand:CC 0 "d_operand" "") > (match_operand:CC 1 "fcc_reload_operand" ""))] > "reload_completed && ISA_HAS_8CC && TARGET_HARD_FLOAT && ISA_HAS_CONDMOVE > && !CANNOT_CHANGE_MODE_CLASS(CCmode, SImode, > > REGNO_REG_CLASS(REGNO(operands[0])))" > [(set (match_dup 2) (match_dup 3)) > (set (match_dup 2) > (if_then_else:SI > (eq:SI (match_dup 1) > (match_dup 4)) > (match_dup 2) > (match_dup 4)))] > " > { > operands[2] = gen_rtx_REG(SImode, REGNO(operands[0])); > operands[3] = GEN_INT(0x3f800000); > operands[4] = const0_rtx; > } > ") > > But I have two questions. > > Firstly, the lui_movf pattern is output as > "lui\t%0,0x3f80\n\tmovf\t%0,%.,%1" in mips_output_move, > why 0x3f80? is it some kind of magic number, or anything else important?
It's the encoding of 1.0f (single precision). The point is that we want something we can safely compare with 0.0f using floating-point instructions. "Safe" means "without generating any kind of exception", so a subnormal representation like 0x00000001 isn't acceptable. 1.0f seems as good a value as any. > Secondly, I have to change mode of operands[0] into SImode when > splitting, otherwise there is no > insn pattern matching the first insn generated. > Since no new REG generated I assuming the mode transforming is OK > here, any suggestion? Yes, this is OK. Your split looks good, but I don't see any reason for the !CANNOT_CHANGE_MODE_CLASS condition. Couple of minor suggestions: - There is no need for the double quotes around the { ... }. Plain { ... } is better. (Support for plain { ... } was added a few years ago, so you can still see some older code that uses "{ ... }". But { ... } is better for new code.) - It's generally better to restrict match_dups to things that depend on the operands of the original insn. In the above, it'd be better to replace (match_dup 4) with (const_int 0) and then not set operands[4] in the C code. (match_dup 3) is OK as an exception because read-rtl.c doesn't support hex constants yet... Richard