@@ -2511,27 +2511,29 @@ static unsigned ComputeNumSignBitsImpl(const Value *V, unsigned Depth,
2511
2511
// extended, shifted, etc).
2512
2512
return ComputeNumSignBits (U->getOperand (0 ), Depth + 1 , Q);
2513
2513
2514
- case Instruction::ShuffleVector:
2514
+ case Instruction::ShuffleVector: {
2515
2515
// If the shuffle mask contains any undefined elements, that element of the
2516
2516
// result is undefined. Propagating information from a source operand may
2517
2517
// not be correct in that case, so just bail out.
2518
2518
if (cast<ShuffleVectorInst>(U)->getMask ()->containsUndefElement ())
2519
2519
break ;
2520
2520
2521
- assert ((!isa<UndefValue>(U->getOperand (0 )) ||
2522
- !isa<UndefValue>(U->getOperand (1 )))
2523
- && " Should have simplified shuffle with 2 undef inputs" );
2521
+ // If everything is undef, we can't say anything. This should be simplified.
2522
+ Value *Op0 = U->getOperand (0 ), *Op1 = U->getOperand (1 );
2523
+ if (isa<UndefValue>(Op0) && isa<UndefValue>(Op1))
2524
+ break ;
2524
2525
2525
2526
// Look through shuffle of 1 source vector.
2526
- if (isa<UndefValue>(U-> getOperand ( 0 ) ))
2527
- return ComputeNumSignBits (U-> getOperand ( 1 ) , Depth + 1 , Q);
2528
- if (isa<UndefValue>(U-> getOperand ( 1 ) ))
2529
- return ComputeNumSignBits (U-> getOperand ( 0 ) , Depth + 1 , Q);
2527
+ if (isa<UndefValue>(Op0 ))
2528
+ return ComputeNumSignBits (Op1 , Depth + 1 , Q);
2529
+ if (isa<UndefValue>(Op1 ))
2530
+ return ComputeNumSignBits (Op0 , Depth + 1 , Q);
2530
2531
2531
2532
// TODO: We can look through shuffles of 2 sources by computing the minimum
2532
2533
// sign bits for each operand (similar to what we do for binops).
2533
2534
break ;
2534
2535
}
2536
+ }
2535
2537
2536
2538
// Finally, if we can prove that the top bits of the result are 0's or 1's,
2537
2539
// use this information.
0 commit comments