This is an archive of the discontinued LLVM Phabricator instance.

[InstSimplify] Update foldings to constants to consider Q.AllowRefinement
AbandonedPublic

Authored by aqjune on Mar 13 2021, 9:25 AM.

Details

Summary

This is a follow-up of D98391 and fixes a few foldings from non-constants to constants to be activated only when Q.AllowRefinement is true.
Foldings from non-constants to constants are considered only, because

  • They are more likely to be the source of end-to-end miscompilation than other foldings. See the example from unit test diff below
  • Changing all of these at once is likely to cause significant performance regression and getting the patch reviewed isn't realistic.

After this patch, one unit test needed to be changed:

  %v = select (x == 0), 0, (x & y)
=>
  %v = x & y

Since SimplifyAndInst(0 & y) was returning 0, the whole formula was simplified into x & y.
This is incorrect because the result becomes more poisonous if y was poison.
Currently it does not cause end-to-end miscompilation because poison constant does not appear frequently, but this is likely to cause problem in the future.

Diff Detail