This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] Use poison constant to represent the result of unreachable instrs
ClosedPublic

Authored by aqjune on Jun 19 2021, 11:02 PM.

Details

Summary

This patch updates InstCombine to use poison constant to represent the resulting value of (either semantically or syntactically) unreachable instrs, or a don't-care value of an unreachable store instruction.

This allows more aggressive folding of unused results, as shown in llvm/test/Transforms/InstCombine/getelementptr.ll .

Diff Detail

Event Timeline

aqjune created this revision.Jun 19 2021, 11:02 PM
aqjune requested review of this revision.Jun 19 2021, 11:02 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 19 2021, 11:02 PM
aqjune added inline comments.Jun 19 2021, 11:05 PM
llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
717

Oops, this part does not belong to this patch; I'll remove this

aqjune updated this revision to Diff 353223.Jun 19 2021, 11:08 PM

Remove the update at createOverflowTuple

aqjune edited the summary of this revision. (Show Details)Jun 19 2021, 11:10 PM
nikic accepted this revision.Jun 20 2021, 2:28 AM

LGTM, but please drop the "use poison instead of undef" comments -- I don't think using poison instead of undef for dead code requires any explicit justification.

llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
1441–1442

Might want to check for PoisonValue here, to canonicalize a pre-existing undef operand.

This revision is now accepted and ready to land.Jun 20 2021, 2:28 AM
aqjune updated this revision to Diff 353255.Jun 20 2021, 5:58 PM

Address comments

This revision was landed with ongoing or failed builds.Jun 20 2021, 5:59 PM
This revision was automatically updated to reflect the committed changes.
aqjune marked an inline comment as done.Jun 20 2021, 5:59 PM