This is an archive of the discontinued LLVM Phabricator instance.

[HACK] X86: Disable isCopyInstrImpl for undef subregister defs
ClosedPublic

Authored by arsenm on Jul 24 2023, 12:40 PM.

Details

Summary

This is a workaround for a coalescer bug where coalescing
SUBREG_TO_REG ends up losing the liveness of the high bits of the
source register. The result is an incorrect undef subregister def
instead of preserving the high values. Work around the observed
failure after the resulting mov is eliminated during allocation until
a proper fix is ready. I believe the proper fix is to make
SUBREG_TO_REG use a tied operand.

Diff Detail

Event Timeline

arsenm created this revision.Jul 24 2023, 12:40 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 24 2023, 12:40 PM
arsenm requested review of this revision.Jul 24 2023, 12:40 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 24 2023, 12:40 PM
Herald added a subscriber: wdng. · View Herald Transcript
vitalybuka accepted this revision.EditedJul 24 2023, 1:25 PM
vitalybuka added a subscriber: vitalybuka.

Thanks you!

LGTM, but I am not expert on CodeGen, please look for more reviews if needed.

Would you like to add one of reproducers as a test?

  • check-all is green for me
  • original issue is gone
  • Perf is not changed on one of our large server benchmarks
This revision is now accepted and ready to land.Jul 24 2023, 1:25 PM
arsenm planned changes to this revision.Jul 24 2023, 1:26 PM

I think I have a fix in the coalescer, working on refining the tests

arsenm requested review of this revision.Jul 24 2023, 2:55 PM
This revision is now accepted and ready to land.Jul 24 2023, 2:55 PM

I think the real fix is to make SUBREG_TO_REG use a tied operand with a subregister but that will be a much larger patch

arsenm updated this revision to Diff 543736.Jul 24 2023, 4:00 PM
arsenm edited the summary of this revision. (Show Details)
arsenm added inline comments.
llvm/lib/Target/X86/X86InstrInfo.cpp
3657

I should have a more general fix ready tomorrow which adds an implicit-def during coalescing. The handling here then needs to guard against implicit-defs (and report the full def super register intsead of the physical subreg undef def)

Better version ends at D156346

RKSimon accepted this revision.Jul 28 2023, 5:06 AM

LGTM as a stopgap