[PATCH] D81918: [PowerPC] Support lowering int-to-fp on ppc_fp128

Ulrich Weigand via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 30 02:08:21 PDT 2020


uweigand added a comment.

For unsigned conversion, the input is treated as signed here, and the result fixed up by adding 2^N; something along the lines of

  (signed)N >= 0 ? signed_to_FP((signed)N) : signed_to_FP(N - 2^N) + (FP)2^N

For strict operation, we need to verify that the result is correct with any setting of the current rounding mode, and that the overall exception status after the two operations (signed_to_FP and the FADD) matches the intended semantics of the unsigned_to_FP operation.   I believe in general this is not the case; specifically, there may be problems if the input (interpreted as signed) is not exactly representable as FP number,

If the input type is i32 or i64, that's probably not a problem, given that all such numbers are exactly representable as ppc_f128.  However, if the input type is i128, this is no longer the case.

If you look at SelectionDAGLegalize::ExpandLegalINT_TO_FP, which uses a similar algorithm, you'll see that it switches to a different one in the case where not all inputs may be representable.   I think we'll have to do something similar here for full correctness.

(OTOH given that this affects only the i128->ppc_f128 case, which should be relatively rare, and I think isn't even fully correct in all cases in non-strict mode even today, maybe this can be done later.   But at least there should be a FIXME.)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D81918/new/

https://reviews.llvm.org/D81918





More information about the llvm-commits mailing list