This is an archive of the discontinued LLVM Phabricator instance.

[Hexagon] Use stable sort for HexagonShuffler to remove non-deterministic ordering
ClosedPublic

Authored by mgrang on Nov 19 2017, 11:58 AM.

Details

Summary

This fixes failures in the following tests uncovered by D39245:

LLVM :: CodeGen/Hexagon/args.ll
LLVM :: CodeGen/Hexagon/constp-extract.ll
LLVM :: CodeGen/Hexagon/expand-condsets-basic.ll
LLVM :: CodeGen/Hexagon/gp-rel.ll
LLVM :: CodeGen/Hexagon/packetize_cond_inst.ll
LLVM :: CodeGen/Hexagon/simple_addend.ll
LLVM :: CodeGen/Hexagon/swp-stages4.ll
LLVM :: CodeGen/Hexagon/swp-vmult.ll
LLVM :: CodeGen/Hexagon/swp-vsum.ll
LLVM :: MC/Hexagon/align.s
LLVM :: MC/Hexagon/asmMap.s
LLVM :: MC/Hexagon/dis-duplex-p0.s
LLVM :: MC/Hexagon/double-vector-producer.s
LLVM :: MC/Hexagon/inst_select.ll
LLVM :: MC/Hexagon/instructions/j.s

Diff Detail

Repository
rL LLVM

Event Timeline

mgrang created this revision.Nov 19 2017, 11:58 AM

In HexagonShuffler.h, the lessCore and lessCVI comparators sort insts based on the number of units set. Now, two insts can have the same units set so their relative ordering is not defined.
We could add an index field as a tie-breaker but that would mean changes to function APIs which I felt could be an overkill. Hence, I went with the simpler approach to just use stable_sort instead.
Please let me know your thoughts on this.

Ping for reviews please.

kparzysz accepted this revision.Nov 27 2017, 10:53 AM
This revision is now accepted and ready to land.Nov 27 2017, 10:53 AM
This revision was automatically updated to reflect the committed changes.