Page MenuHomePhabricator

[PowerPC] Promote the i1 to i64 for SINT_TO_FP/FP_TO_SINT
ClosedPublic

Authored by steven.zhang on Nov 24 2020, 7:17 PM.

Details

Summary

i1 is the native type for PowerPC if crbits is enabled. However, we need to promote the i1 to i64 as we didn't have the pattern for i1. This patch fix the crash for this simple case:

define i1 @test(double %m)  {
entry:
  %conv = fptoui double %m to i1
  ret i1 %conv
}
LLVM ERROR: Cannot select: t3: i1 = fp_to_uint t2
  t2: f64,ch = CopyFromReg t0, Register:f64 %0
    t1: f64 = Register %0
In function: test
PLEASE submit a bug report to xl_beta@ca.ibm.com and include the crash backtrace.
Stack dump:

Diff Detail

Event Timeline

steven.zhang created this revision.Nov 24 2020, 7:17 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 24 2020, 7:17 PM
steven.zhang requested review of this revision.Nov 24 2020, 7:17 PM
qiucf added a comment.Nov 26 2020, 1:03 AM

After applying this patch, I enumerated signed/unsigned conversion between i1~i128 and f32/f64/f128/ppcf128, only ppcf128-i1 still crashes:

define i1 @pq_s1(ppc_fp128 %a) {
  %b = fptosi ppc_fp128 %a to i1
  ret i1 %b
}

define i1 @pq_u1(ppc_fp128 %a) {
  %b = fptoui ppc_fp128 %a to i1
  ret i1 %b
}
Assertion failed: (LC != RTLIB::UNKNOWN_LIBCALL && "Unsupported FP_TO_SINT!"), function ExpandFloatOp_FP_TO_SINT, file llvm-project/llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp

Similar promotion can also fix this?

steven.zhang added a comment.EditedNov 26 2020, 6:20 PM

After applying this patch, I enumerated signed/unsigned conversion between i1~i128 and f32/f64/f128/ppcf128, only ppcf128-i1 still crashes:

define i1 @pq_s1(ppc_fp128 %a) {
  %b = fptosi ppc_fp128 %a to i1
  ret i1 %b
}

define i1 @pq_u1(ppc_fp128 %a) {
  %b = fptoui ppc_fp128 %a to i1
  ret i1 %b
}
Assertion failed: (LC != RTLIB::UNKNOWN_LIBCALL && "Unsupported FP_TO_SINT!"), function ExpandFloatOp_FP_TO_SINT, file llvm-project/llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp

Similar promotion can also fix this?

As we have tried to promote the i1 to i64, but it still failed for ppc f128. So, there is other issue hidden I think. We can have some follow up to fix it.

qiucf accepted this revision as: qiucf.Nov 30 2020, 1:31 AM

LGTM. Thanks for fixing this.

This revision is now accepted and ready to land.Nov 30 2020, 1:31 AM