[PATCH] D34762: [JumpThreading] Add a pattern to TryToUnfoldSelectInCurrBB()

Haicheng Wu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 5 08:49:32 PDT 2017


haicheng marked an inline comment as done.
haicheng added inline comments.


================
Comment at: lib/Transforms/Scalar/JumpThreading.cpp:2168
+    SelectInst *SI = nullptr;
+    for (Use &U : PN->uses()) {
+      if (ICmpInst *Cmp = dyn_cast<ICmpInst>(U.getUser())) {
----------------
junbuml wrote:
> haicheng wrote:
> > junbuml wrote:
> > > Do you intentionally go through all users of the PHI by removing the check PN->hasOneUse() ?
> > Yes, I found out that it is useful when benchmarking.
> Can you add a test case for this?  Don't you think this change itself should be a separate patch?
I added a test case.  Basically, I find out that this pattern is common and it is beneficial to split.

```
bb:
   %p = phi [0, %bb1], [1, %bb2], [2, %bb3], [3, %bb4], ...
   %c = cmp sgt %p, 2
   %s = select %c, trueval, %p
```
PHI is used in both cmp and select.  If it is okay, I prefer to including it in this patch.


Repository:
  rL LLVM

https://reviews.llvm.org/D34762





More information about the llvm-commits mailing list