This is an archive of the discontinued LLVM Phabricator instance.

A workaround for the bug caused by descrepancy between loop-unswitch and GVN about branch on undef
ClosedPublic

Authored by wmi on Jul 24 2017, 12:03 PM.

Details

Summary

This is a workaround for the bug described in http://lists.llvm.org/pipermail/llvm-dev/2017-July/115497.html. The temporary solution is to add a function EqualityPropUnSafe. In EqualityPropUnSafe, for some simple patterns we can know the equality comparison may contains undef, so we regard such comparison as unsafe and will not do do-unswitching for them. We also need to disable the select simplification when one of its operand is undef and its result feeds into equality comparison.

The patch cannot clear the safety issue caused by the bug, but it can suppress the issue from happening to some extent.

I think the change may have little performance impact. For the change to disable select simplification, I tried spec2000 and spec2006, the related path is never taken. For llvm bootstrap, it is taken only four times.

Diff Detail

Repository
rL LLVM

Event Timeline

wmi created this revision.Jul 24 2017, 12:03 PM
davidxl added inline comments.Jul 24 2017, 11:57 PM
lib/Transforms/InstCombine/InstCombineSelect.cpp
1161 ↗(On Diff #107935)

Is it better to document the bug number here?

lib/Transforms/Scalar/LoopUnswitch.cpp
556 ↗(On Diff #107935)

Document the bug number?

nlopes accepted this revision.Jul 25 2017, 1:03 AM

LGTM.
Seems good enough to me as a temporary hack.

This revision is now accepted and ready to land.Jul 25 2017, 1:03 AM
wmi marked 2 inline comments as done.Jul 25 2017, 4:36 PM
This revision was automatically updated to reflect the committed changes.