[PATCH] D23200: [LVI] Handle conditions in the form of (cond1 && cond2)

Sanjoy Das via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 9 14:57:00 PDT 2016


sanjoy accepted this revision.
sanjoy added a comment.
This revision is now accepted and ready to land.

lgtm with comments addressed


================
Comment at: lib/Analysis/LazyValueInfo.cpp:1244
@@ +1243,3 @@
+  LVILatticeVal LHS, RHS;
+  bool LHSResult = GetFromCondition(BO->getOperand(0), LHS);
+  bool RHSResult = GetFromCondition(BO->getOperand(1), RHS);
----------------
I'd suggest using a visited set here.  That way you don't infinitely recurse in unreachable code (I'm not sure if that is filtered out already) and won't have exponential time complexity for cases like

```
%c0 = icmp ..
%c1 = icmp ..
%a0 = and %c0, %c1
%a1 = and %a0, %a0
%a2 = and %a1, %a1
%a3 = and %a2, %a2
%a4 = and %a3, %a3
%a5 = and %a4, %a4
...
```


================
Comment at: test/Transforms/CorrelatedValuePropagation/add.ll:155
@@ +154,3 @@
+  %cmp.1 = icmp slt i32 %a, 100
+  %cmp.2 = icmp sgt i32 %a, 0
+  %cmp.3 = and i1 %cmp.2, %flag
----------------
I'd also throw in a

```
if (a s< Unknown && Unknown2)
  b = a + 1;
```

to

```
if (a s< Unknown && Unknown2)
  b = a nsw+ 1;
```

type transform.


https://reviews.llvm.org/D23200





More information about the llvm-commits mailing list