This is an archive of the discontinued LLVM Phabricator instance.

[InstSimplify] Add more poison folding optimizations
ClosedPublic

Authored by aqjune on Jun 21 2021, 11:56 AM.

Details

Summary

This adds more poison folding optimizations to InstSimplify.

Since all binary operators propagate poison, these are fine.

Also, the precondition of select cond, undef, x -> x is relaxed to allow the case when x is undef.

Diff Detail

Event Timeline

aqjune created this revision.Jun 21 2021, 11:56 AM
aqjune requested review of this revision.Jun 21 2021, 11:56 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 21 2021, 11:56 AM
nikic added inline comments.Jun 21 2021, 12:30 PM
llvm/lib/Analysis/InstructionSimplify.cpp
749

I'd prefer the PoisonValue checks to happen independently of the isUndefValue checks, because these are valid even if undef value folding is disabled (folding poison does not create an assumption for a specific undef value).

aqjune added inline comments.Jun 22 2021, 7:26 AM
llvm/lib/Analysis/InstructionSimplify.cpp
749

That is correct. I was concerned about whether independently dealing with it might confuse people or not.
Anyway, since it allows more optimization, I'll update this patch to do so.

aqjune updated this revision to Diff 353648.Jun 22 2021, 7:55 AM
  • Make poison check independent from Q.isUndefValue query calls
  • Remove xor poison, X -> poison folding to avoid xor poison, poison -> poison as mentioned in D104648
aqjune marked an inline comment as done.Jun 22 2021, 7:55 AM
nikic accepted this revision.Jun 23 2021, 1:45 AM

LGTM

llvm/test/Transforms/InstCombine/select-binop-cmp.ll
1270

While you're in the area: poisong -> poison

This revision is now accepted and ready to land.Jun 23 2021, 1:45 AM
This revision was automatically updated to reflect the committed changes.
aqjune marked an inline comment as done.Jun 23 2021, 4:26 AM