Similar in spirit to D20497 :
If all elements of a constant vector are known non-zero, then we can say that the whole vector is known non-zero.
It seems like we could extend this to FP scalar/vector too, but isKnownNonZero() says it only works for integers and pointers for now.
Details
Details
Diff Detail
Diff Detail
Event Timeline
Comment Actions
LGTM with nits.
lib/Analysis/ValueTracking.cpp | ||
---|---|---|
1686–1689 | 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. |
lib/Analysis/ValueTracking.cpp | ||
---|---|---|
1686–1689 | Sure - I actually had written it that way initially, but I thought the nit would be to make it one big 'if'. :) |
Might be easier to read as:
While it is a little more code, I think it's a little easier to follow along.