[PATCH] D107170: [InstCombine] canonicalize cmp-of-bitcast-of-vector-cmp to use zero constant

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 30 08:25:12 PDT 2021


spatel created this revision.
spatel added reviewers: lebedev.ri, RKSimon, pengfei, craig.topper.
Herald added subscribers: hiraditya, mcrosier.
spatel requested review of this revision.
Herald added a project: LLVM.

We can invert a compare constant and compare predicate and preserve the logic as shown in this sampling:
https://alive2.llvm.org/ce/z/YAXbfs
(In theory, we could deal with non-all-ones/zero as well, but it doesn't seem worthwhile.)

I noticed this as a part of the x86 codegen difference in https://llvm.org/PR51259 - that ends up using "test" instead of "not + cmp" in that example.

This pattern also shows up in https://llvm.org/PR41312 and https://llvm.org/PR50798 .


https://reviews.llvm.org/D107170

Files:
  llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
  llvm/test/Transforms/InstCombine/icmp-vec.ll
  llvm/test/Transforms/PhaseOrdering/X86/vector-reductions-logical.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D107170.363099.patch
Type: text/x-patch
Size: 9756 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210730/7026e9b9/attachment.bin>


More information about the llvm-commits mailing list