[PATCH] D72976: [PatternMatch] Make m_c_ICmp swap the predicate (PR42801)

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Jan 18 04:14:38 PST 2020


nikic created this revision.
nikic added reviewers: lebedev.ri, spatel.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72976

Files:
  llvm/include/llvm/IR/PatternMatch.h
  llvm/lib/Analysis/InstructionSimplify.cpp
  llvm/lib/Analysis/ValueTracking.cpp
  llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
  llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D72976.238948.patch
Type: text/x-patch
Size: 8545 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200118/77aa1443/attachment.bin>


More information about the llvm-commits mailing list