This is an archive of the discontinued LLVM Phabricator instance.

[AArch64] Type conversion bug when anlyze compare
ClosedPublic

Authored by David.Xu on Aug 4 2014, 12:35 AM.

Details

Summary

In analyzeCompare() function in AArch64InstrInfo.cpp, the return val type of decodeLogicalImmediate is uint64_t, while CmpValue is int, it causes a bug when converting uint64_t to int. The bug was found in spec2006-483.xalancbmk. CmpValue is only used to compare with zero in OptimizeCompareInstr(), so we can fix it by comparing it with zero in analyzeCompare().

Diff Detail

Event Timeline

David.Xu updated this revision to Diff 12150.Aug 4 2014, 12:35 AM
David.Xu retitled this revision from to Type conversion bug when anlyze compare .
David.Xu updated this object.
David.Xu edited the test plan for this revision. (Show Details)
David.Xu added a subscriber: Unknown Object (MLST).
David.Xu retitled this revision from Type conversion bug when anlyze compare to [AArch64] Type conversion bug when anlyze compare .Aug 4 2014, 12:43 AM
David.Xu added a reviewer: t.p.northover.
t.p.northover edited edge metadata.Aug 5 2014, 8:02 AM

Shouldn't you be able to produce a test for this? It doesn't seem impossibly difficult to distil the key features from the SPEC case.

I think the change also needs better documentation. You're changing the meaning of CmpValue here: no-one can ever rely on any nonzero value after this commit. That might be OK, since we don't want to anyway right now, but I think it needs to be clear and blow up horribly.

Perhaps making sure CmpValue is always 0 or 1, and asserting that in optimizeCompare? (With an appropriate comments about the limitation and why it was introduced).

Cheers.

Tim.

David.Xu updated this revision to Diff 12266.Aug 6 2014, 8:25 PM
David.Xu edited edge metadata.

Test case is added in the new patch. Without the patch, an ANDS instruction will be deleted when doing peephole optimization.

Thanks for the test, but what about the other comments? I still think the code change leaves that area too ambiguous.

Cheers.

Tim.

Yes, This patch changes the meaning of CmpValue. It may not be the best way to solve this problem, but it has no effect on the other compare instructions and other backends comparing to the way of changing the interface of the function. And appropriate comments are added in optimizeCompare.

David.Xu updated this revision to Diff 12267.Aug 6 2014, 10:02 PM
David.Xu updated this revision to Diff 12275.Aug 7 2014, 3:26 AM

I have converted all of the CmpValue to 0 or 1, and also added assertion in optimizeCompare. For that our daily performance test have broken down for a long time, please review it ASAP. Thank you!

David.Xu updated this revision to Diff 12276.Aug 7 2014, 3:34 AM
t.p.northover accepted this revision.Aug 8 2014, 3:52 AM
t.p.northover edited edge metadata.

Thanks David,

I think that looks OK now. Hopefully any future meddlers will notice the warnings.

Cheers.

Tim.

This revision is now accepted and ready to land.Aug 8 2014, 3:52 AM
Eugene.Zelenko added a subscriber: Eugene.Zelenko.

Committed in rL215206.