The 64-bit RISCV target has no legal i32 type. So when SelectionDAG
is legalizing the types for FPOWI the exponent is promoted to i64.
However, the FPOWI/STRICT_FPOWI are defined as having undefined
result if the exponent is larger than i32 (it should probably say
"if the exponent is larger than sizeof(int) for the target" as it
shold be possible to lower those nodes to RTLIB::POWI libcalls and
those runtime library functions is using "int" as input arguments).
This patch can be seen as a workaround to avoid that we promote
the exponent to i64 (making the result undefined). As a simple
solution we expand FPOWI/STRICT_FPOWI into SINT_TO_FP+FPOW. This
is the same rewrite as normally done by LegalizeDAG when the
RTLIB::POWI libcalls aren't allowed.
I leave it as a future FIXME to implement legalization/lowering
of FPOWI/STRICT_FPOWI into using RTLIB::POWI libcalls again. Someone
that knows about RISCV and calling conventions can perhaps figure
out how to do that properly.
clang-format not found in user’s local PATH; not linting file.