matt-kempster/m2c

Handle f64 values in phis

zbanks opened this issue · 0 comments

Brought up by JoshDuMan on Discord from the appendGfx_message function in PM.

There is in the function that Ethan and I were working on, a set of inequalities that do

if (x > 1.0) {
} else if (X < 1.0) {
}

where 1.0 is a double
For the first load, mips2c correctly sees that the load into the comparison register is a double
But when the double 1.0 is reused for the second case, it seems to only see the 0 load into the register and outputs instead

if (x > 1.0) {
} else if (X < 0.0) {
}

The issue here is that the rhs of the comparison (1.0/0.0) is from a PhiExpr. In assign_phis(), although the type of the phi is known to be f64, it only reads the value from final_register_states of the main float reg, instead of combining it like InstrArgs.dreg() does.

This may get even more complicated if both regs are PhiExprs?