[PATCH] D19559: [LVI] Exploit trivial range information from unknown RHS of icmp

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Wed May 4 12:12:52 PDT 2016


reames added inline comments.

================
Comment at: lib/Analysis/LazyValueInfo.cpp:1162
@@ +1161,3 @@
+    // A <u B for any A and B implies A <u UINT_MAX on success path
+    if ((ICI->getPredicate() == ICmpInst::ICMP_SLT ||
+         ICI->getPredicate() == ICmpInst::ICMP_ULT)) {
----------------
sanjoy wrote:
> I wouldn't put all this logic here. Instead, it is easier to do:
> 
> ```
> ConstantRange RHSRange = FullRange;
> ConstantRange LHSRange = makeAllowedRange(ICI->getPredicate(), RHSRange);
> if (LHSRange is not full set)
>   Result = LVILatticeVal::getRange(LHSRange);
> ```
> 
> Later you can improve precision by making `RHSRange` more precise.
I really like this idea.  I'm going to rewrite this patch when I get a chance and probably simplify a lot of other code nearby using the same trick.  


http://reviews.llvm.org/D19559





More information about the llvm-commits mailing list