This is an archive of the discontinued LLVM Phabricator instance.

[PatternMatch] Make m_c_ICmp swap the predicate (PR42801)
ClosedPublic

Authored by nikic on Jan 18 2020, 4:13 AM.

Details

Summary

This addresses https://bugs.llvm.org/show_bug.cgi?id=42801. The m_c_ICmp() matcher is changed to provide the swapped predicate it the operands are swapped.

Existing uses of m_c_ICmp() fall in one of two categories: Working on equality predicates only, where swapping is irrelevant. Or performing a manual swap, in which case this patch removes it.

The only exception is the foldICmpWithLowBitMaskedVal() fold, which does not swap the predicate, and instead reasons about whether a swap occurred or not for each predicate. Getting the swapped predicate allows us to merge the logic for pairs of predicates, instead of duplicating it.

Diff Detail

Event Timeline

nikic created this revision.Jan 18 2020, 4:13 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 18 2020, 4:13 AM
spatel accepted this revision.Jan 20 2020, 6:12 AM

LGTM

llvm/include/llvm/IR/PatternMatch.h
1888

Need to update this comment.

This revision is now accepted and ready to land.Jan 20 2020, 6:12 AM
This revision was automatically updated to reflect the committed changes.