This is an archive of the discontinued LLVM Phabricator instance.

[DAG] Strip poison generating flags in freeze(op()) -> op(freeze()) fold
ClosedPublic

Authored by RKSimon on Aug 21 2022, 11:28 AM.

Details

Summary

This patch follows the InstCombine approach of stripping poison generating flags (nsw/nuw from add/sub etc.) to allow us to push a freeze() through the op. Unlike InstCombine it doesn't retain any flags, but we have plenty of DAG folds that do the same thing already. We assert that the newly generated op isGuaranteedNotToBeUndefOrPoison.

Similar to the ValueTracking approach, isGuaranteedNotToBeUndefOrPoison has been updated to confirm that if an op can't create undef/poison and its operands are guaranteed not to be undef/poison - then its not undef/poison. This is just for the generic opcodes - target specific opcodes will need to do this manually just in case they have some special cases.

Diff Detail

Event Timeline

RKSimon created this revision.Aug 21 2022, 11:28 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 21 2022, 11:28 AM
RKSimon requested review of this revision.Aug 21 2022, 11:28 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 21 2022, 11:28 AM

It's coaser than InstCombine

coaser?

RKSimon edited the summary of this revision. (Show Details)Aug 21 2022, 12:48 PM

It's coaser than InstCombine

coaser?

this is what happens when spellcheck fails :)

RKSimon edited the summary of this revision. (Show Details)Aug 21 2022, 12:51 PM
This revision is now accepted and ready to land.Aug 25 2022, 12:29 PM
RKSimon edited the summary of this revision. (Show Details)Aug 26 2022, 12:58 AM