This is an archive of the discontinued LLVM Phabricator instance.

[SPARC] Fix SELECT_REG emission for f128s
ClosedPublic

Authored by koakuma on Dec 21 2022, 3:30 PM.

Details

Summary

In LowerSELECT_CC, SELECT_REG between two f128s should only be emitted if we have hardware quadfloat enabled.

This should fix issue #59646 (https://github.com/llvm/llvm-project/issues/59646).

Diff Detail

Event Timeline

koakuma created this revision.Dec 21 2022, 3:30 PM
koakuma requested review of this revision.Dec 21 2022, 3:30 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 21 2022, 3:30 PM
arsenm added inline comments.Dec 21 2022, 3:31 PM
llvm/lib/Target/Sparc/SparcISelLowering.cpp
2644

This is enforced during construction?

2659

Could you check isTypeLegal instead?

koakuma added inline comments.Dec 21 2022, 4:28 PM
llvm/lib/Target/Sparc/SparcISelLowering.cpp
2644

Yeah it should, lemme remove this assert.

2659

I don't think that I could use isTypeLegal here?
Disabling hardquad only turns off the instructions, but the registers are still there (this is because the ISA defines an f128 register to be simply a group of four f32 registers), so isTypeLegal(f128) will always return true regardless of whether we have hardquad instructions or not.

koakuma updated this revision to Diff 484715.Dec 21 2022, 4:29 PM

Address review comments, and add a hardquad variant of the test case.

arsenm added inline comments.Dec 21 2022, 4:31 PM
llvm/lib/Target/Sparc/SparcISelLowering.cpp
2659

Is there another affirmative way to express the condition?

koakuma added inline comments.Dec 21 2022, 4:57 PM
llvm/lib/Target/Sparc/SparcISelLowering.cpp
2659

The most I can think is adding another if inside it like so:

if (is64Bit && ...) {
  if (TrueVal.getValueType() == MVT::f128 && !hasHardQuad) {
    // do nothing
  } else {
    return ...
  }
}

Would this be okay?

koakuma updated this revision to Diff 484716.Dec 21 2022, 5:07 PM

Update conditionals, separate the f128 part for easier reading.

arsenm added inline comments.Dec 21 2022, 5:39 PM
llvm/lib/Target/Sparc/SparcISelLowering.cpp
2659

It was better before. I meant more permit cases where SELECT_REG is legal. You're still fundamentally excluding f128 rather than including other types

koakuma updated this revision to Diff 484729.Dec 21 2022, 6:23 PM

Address review comment: list all the types that is supported by SELECT_REG.

ro added a comment.Dec 22 2022, 5:17 AM

I just ran 2-stage builds on sparcv9-sun-solaris2.11 (with both gcc 12.2.0 and clang 15.0.0 in stage 1) : the builds completed successfully and
test results are back to what they were about a month ago (with two unrelated issues). Thanks.

arsenm accepted this revision.Dec 22 2022, 5:26 AM
This revision is now accepted and ready to land.Dec 22 2022, 5:26 AM
This revision was automatically updated to reflect the committed changes.