[PATCH] D44626: [InstCombine] Fold (A OR B) AND B code sequence over Phi node

Hiroshi Inoue via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 19 23:10:03 PDT 2018


inouehrs updated this revision to Diff 143229.
inouehrs added a comment.

- addressed comments from Eli.

> Only allowing 64-bit values seems overly restrictive.

I agree. I relaxed the condition.

> We don't usually like to walk uses like this; can you start the pattern-match from the "and"?

I made the pattern match start from "and".

> Do you need to check hasOneUse() on the "or" here?

This patch does not eliminate or modify "or" and does not require hasOneUse on it, although the later optimization may further optimize "or".

> Looking specifically for zext+shl seems overly specific to your testcase

I generalized the code using `computeKnownBits` since `SimplifyAndInst` does not identify this pattern.

> Any idea how frequently this triggers on general code (the LLVM testsuite, or something like that)?

While compiling LLVM, this modification happens about 440 times. In LLVM testsuite it happens only three times.
I think newer programs tend to use a value pair as the return value type more frequently.

Thank you for the comments.


https://reviews.llvm.org/D44626

Files:
  lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
  lib/Transforms/InstCombine/InstCombineInternal.h
  test/Transforms/InstCombine/fold-or-phi.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44626.143229.patch
Type: text/x-patch
Size: 11673 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180420/0fa5b258/attachment.bin>


More information about the llvm-commits mailing list