[PATCH] D28625: [InstCombine] try to shrink bitwise logic with phi operand

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 12 12:52:51 PST 2017


spatel created this revision.
spatel added reviewers: efriedma, majnemer, hfinkel.
spatel added subscribers: llvm-commits, RKSimon.
Herald added a subscriber: mcrosier.

The test case is based on an example from:
http://www.gdcvault.com/play/1023026/Taming-the-Jaguar-x86-Optimization

  bool ArraySearch(int count, uint32_t needle, uint32_t haystack[]) {
    bool found = false;
    for (int i = 0; i < count; ++i)
      found |= needle == haystack[i];
    return found;
  }

...so I think the pattern could show up in any "all_of" or "any_of" style of loop. I checked that the loop vectorizer is ok with the change in this case. x86 scalar and vector codegen looks fine with it too.

I'm hoping that https://reviews.llvm.org/D27933 will be approved so we don't have to check the commuted variant (unary cast op is less complex than phi, so it goes to the right side).


https://reviews.llvm.org/D28625

Files:
  lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
  test/Transforms/InstCombine/or.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28625.84167.patch
Type: text/x-patch
Size: 4556 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170112/f30c1bea/attachment.bin>


More information about the llvm-commits mailing list