// Peek through an optional zext of the shift amount.
match(MaskShAmt, m_ZExtOrSelf(m_Value(MaskShAmt)));
- // We have two shift amounts from two different shifts. The types of those
- // shift amounts may not match. If that's the case let's bailout now.
- if (MaskShAmt->getType() != ShiftShAmt->getType())
+ // Verify that it would be safe to try to add those two shift amounts.
+ if (!canTryToConstantAddTwoShiftAmounts(OuterShift, ShiftShAmt, Masked,
+ MaskShAmt))
return nullptr;
// Can we simplify (MaskShAmt+ShiftShAmt) ?
// Peek through an optional zext of the shift amount.
match(MaskShAmt, m_ZExtOrSelf(m_Value(MaskShAmt)));
- // We have two shift amounts from two different shifts. The types of those
- // shift amounts may not match. If that's the case let's bailout now.
- if (MaskShAmt->getType() != ShiftShAmt->getType())
+ // Verify that it would be safe to try to add those two shift amounts.
+ if (!canTryToConstantAddTwoShiftAmounts(OuterShift, ShiftShAmt, Masked,
+ MaskShAmt))
return nullptr;
// Can we simplify (ShiftShAmt-MaskShAmt) ?
; PR49778: this should not be folded to 0.
define i32 @src(i1 %x2) {
; CHECK-LABEL: @src(
-; CHECK-NEXT: ret i32 0
+; CHECK-NEXT: [[X13:%.*]] = zext i1 [[X2:%.*]] to i32
+; CHECK-NEXT: [[_7:%.*]] = shl i32 -1, [[X13]]
+; CHECK-NEXT: [[MASK:%.*]] = xor i32 [[_7]], -1
+; CHECK-NEXT: [[_8:%.*]] = and i32 [[MASK]], [[X13]]
+; CHECK-NEXT: [[_9:%.*]] = shl i32 [[_8]], [[X13]]
+; CHECK-NEXT: ret i32 [[_9]]
;
%x13 = zext i1 %x2 to i32
%_7 = shl i32 4294967295, %x13