[PATCH] D20544: [ValueTracking, InstSimplify] extend isKnownNonZero() to handle vector constants

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Tue May 24 07:06:00 PDT 2016


spatel added inline comments.

================
Comment at: lib/Analysis/ValueTracking.cpp:1686-1689
@@ +1685,6 @@
+      for (unsigned i = 0, e = VTy->getNumElements(); i != e; ++i) {
+        Constant *Elt = C->getAggregateElement(i);
+        if (!Elt || Elt->isNullValue() ||
+            (!isa<UndefValue>(Elt) && !isa<ConstantInt>(Elt)))
+          return false;
+      }
----------------
majnemer wrote:
> Might be easier to read as:
>   Constant *Elt = C->getAggregateElement(i);
>   if (!Elt || Elt->isNullValue())
>     return false;
>   if (!isa<UndefValue>(Elt) && !isa<ConstantInt>(Elt))
>     return false;
> 
> While it is a little more code, I think it's a little easier to follow along.
Sure - I actually had written it that way initially, but I thought the nit would be to make it one big 'if'. :)
I'll flip it back. Thanks!


http://reviews.llvm.org/D20544





More information about the llvm-commits mailing list