This is an archive of the discontinued LLVM Phabricator instance.

PR25754: implement result legalization for UDIVREM8_ZEXT_HREG
ClosedPublic

Authored by tyomitch on Dec 8 2015, 5:09 AM.

Diff Detail

Repository
rL LLVM

Event Timeline

tyomitch updated this revision to Diff 42165.Dec 8 2015, 5:09 AM
tyomitch retitled this revision from to PR25754: implement result legalization for UDIVREM8_ZEXT_HREG.
tyomitch updated this object.
tyomitch added reviewers: spatel, srking.
tyomitch added a subscriber: llvm-commits.

Thanks for working on this!

This patch solves the bug, but I'm not sure if it's the best solution, so I'm cc'ing some people who understand this better than me to take a look too.

  1. The addition to the switch in ReplaceNodeResults() doesn't have a corresponding entry for X86ISD::SDIVREM8_SEXT_HREG (signed + sext). This isn't necessary currently because PerformSExtCombine() is missing the check for an MVT::i64 that exists in PerformZExtCombine() where these nodes are created. But I think that transform should be refactored into shared code, so they stay in sync. If we add that missing type check, we can crash for the SDIVREM case too, so we should handle SDIVREM in the same way as UDIVREM.
  1. I know there are ~600 lines of precedence in crash.ll for not using FileCheck on crashing bugs, but I'd prefer that we check for codegen correctness with the new test case rather than the absence of a crash. "utils/update_llc_test_checks.py" should do well with the small test case; it's probably overkill for the big unreduced cases that already exist in crash.ll though, so you may want to split the regression test into its own or some other file.
tyomitch updated this revision to Diff 42219.Dec 8 2015, 2:03 PM
tyomitch edited edge metadata.

Good point that if SDIVREM8_SEXT_HREG needs not be generated for an i64 result, then UDIVREM8_ZEXT_HREG doesn't need this either.

Happy New Year everyone!

Any comments on the updated patch (from Dec 8th)?

spatel accepted this revision.Jan 5 2016, 11:44 AM
spatel edited edge metadata.

I guess that works too. :)
I thought this way might lead to poorer codegen, but I'm not seeing it with the test case.
Please also add a 'TODO' comment that we should refactor the sext/zext code so that it's not duplicated.

This revision is now accepted and ready to land.Jan 5 2016, 11:44 AM
This revision was automatically updated to reflect the committed changes.