[PATCH] D53987: [ValueTracking] peek through 2-input shuffles in ComputeNumSignBits

Simon Pilgrim via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 2 09:18:39 PDT 2018


RKSimon added inline comments.


================
Comment at: lib/Analysis/ValueTracking.cpp:2526
+    Tmp = std::numeric_limits<unsigned>::max();
+    if (!isa<UndefValue>(U->getOperand(0))) {
+      Tmp = ComputeNumSignBits(U->getOperand(0), Depth + 1, Q);
----------------
spatel wrote:
> RKSimon wrote:
> > Don't you still have to check if a valid shuffle mask element references an UNDEF operand?
> > ```
> > %1 = shufflevector <4 x float> %a0, <4 x float> undef, <4 x i32> <i32 4, i32 5, i32 0, i32 1>
> > ```
> > Or is that guaranteed to have already been handled, the mask element set to undef and caught by containsUndefElement() ?
> Yes, good catch. This is an analysis usable by any pass, so we can't assume canonical code. That means even the existing assert for 2 undefs is not allowed; it has to be a real check.
You can probably go further and replicate the SelectionDAG version's checking of the entire mask - bailing on undef mask elts and determining if it demands/references LHS/RHS operands - and then calling the LHS/RHS num sign bits accordingly.

Might be good prep work for PR36319.


https://reviews.llvm.org/D53987





More information about the llvm-commits mailing list