This is an archive of the discontinued LLVM Phabricator instance.

[PowerPC] fix a bug in redundant compare elimination
ClosedPublic

Authored by inouehrs on Dec 19 2017, 3:47 AM.

Details

Summary

This patch fixes a bug in the redundant compare elimination reported in https://reviews.llvm.org/rL320786 and re-enables the optimization.

The redundant compare elimination assumes that we can replace signed comparison with unsigned comparison for the equality check. But due to the difference in the sign extension behavior we cannot change the opcode if the comparison is against an immediate and the most significant bit of the immediate is one.
The reported problem happen in the following code sequence:

if (a == -1) ...
if (a == (uint16_t)-1) ...

Diff Detail

Repository
rL LLVM

Event Timeline

inouehrs created this revision.Dec 19 2017, 3:47 AM
hfinkel accepted this revision.Dec 19 2017, 7:51 PM

LGTM

This revision is now accepted and ready to land.Dec 19 2017, 7:51 PM
This revision was automatically updated to reflect the committed changes.