On PowerPC VSX targets, fp-to-int will be transformed into xscv* + mfvsr. When the result is to be stored, mfvsr can be replaced by a direct store.
This patch simplifies the optimization by using existing fp-to-int code, which also helps for:
- Strict floating point support of this optimization (in another patch)
- Better codegen from CSE
This change is not enough I think. You extend this function to be used before type legalizer and make this function depend on the caller that will not pass other illegal types except i8 and i16. How about simple types like i2 and i4?
We need a guard for the type in this function.