This is an archive of the discontinued LLVM Phabricator instance.

[CodeGen] Support freeze expand for ppc_fp128
ClosedPublic

Authored by ZhangKang on Apr 16 2020, 12:54 AM.

Details

Summary

The patch https://reviews.llvm.org/D29014 has added the new ISD::FREEZE and can deal with the integer.
The patch https://reviews.llvm.org/D76980 has added SoftenFloatRes_FREEZE for float point.

But from below code, we can know ppc_fp128, it needs expand.

1193   // ppcf128 type is really two f64's.
1194   if (!isTypeLegal(MVT::ppcf128)) {
1195     if (isTypeLegal(MVT::f64)) {
1196       NumRegistersForVT[MVT::ppcf128] = 2*NumRegistersForVT[MVT::f64];
1197       RegisterTypeForVT[MVT::ppcf128] = MVT::f64;
1198       TransformToType[MVT::ppcf128] = MVT::f64;
1199       ValueTypeActions.setTypeAction(MVT::ppcf128, TypeExpandFloat);
1200     } else {
1201       NumRegistersForVT[MVT::ppcf128] = NumRegistersForVT[MVT::i128];
1202       RegisterTypeForVT[MVT::ppcf128] = RegisterTypeForVT[MVT::i128];
1203       TransformToType[MVT::ppcf128] = MVT::i128;
1204       ValueTypeActions.setTypeAction(MVT::ppcf128, TypeSoftenFloat);
1205     }
1206   }

Some cases have gotten assertion for lack of expand for ppc_fp128. For example, below case:
cat ppcf128.mir

--- |
  define ppc_fp128 @freeze_select(ppc_fp128 %a, ppc_fp128 %b) {
    %sel.frozen = freeze ppc_fp128 %a
    %cmp = fcmp one ppc_fp128 %sel.frozen, 0xM00000000000000000000000000000000
    br i1 %cmp, label %select.end, label %select.false

  select.false:                                     ; preds = %0
    br label %select.end

  select.end:                                       ; preds = %0, %select.false
    %sel = phi ppc_fp128 [ %a, %0 ], [ %b, %select.false ]
    ret ppc_fp128 %sel
  }
...

Using below command:

llc -mtriple powerpc64le-unknown-linux-gnu -start-after=codegenprepare ppcf128.mir

You will get below error:

ExpandFloatResult #0: t33: ppcf128 = freeze t9

Do not know how to expand the result of this operator!
UNREACHABLE executed at /home/shkzhang/llvm/llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp:1122!

This patch is to support freeze expand for ppc_fp128 to fix the above error.

Diff Detail

Event Timeline

ZhangKang created this revision.Apr 16 2020, 12:54 AM
ZhangKang edited the summary of this revision. (Show Details)Apr 16 2020, 12:57 AM
ZhangKang planned changes to this revision.Apr 16 2020, 1:02 AM
ZhangKang requested review of this revision.Apr 16 2020, 1:14 AM
efriedma accepted this revision.Apr 16 2020, 4:03 PM

Maybe change the name of the test to ppcf128-freeze.mir? Otherwise LGTM

This revision is now accepted and ready to land.Apr 16 2020, 4:03 PM
ZhangKang updated this revision to Diff 258220.Apr 16 2020, 6:58 PM

Rename the case name from ppcf128.mir to ppcf128_freeze.mir.

ZhangKang updated this revision to Diff 258221.Apr 16 2020, 7:02 PM

Rename the case.

This revision was automatically updated to reflect the committed changes.