As the test shows, we can end up with more instructions than
we started with if we don't include the extra-use check.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@367880
91177308-0d34-0410-b5e6-
96231b3b80d8
// shl (zext X), ShAmt --> zext (shl X, ShAmt)
// This is only valid if X would have zeros shifted out.
Value *X;
- if (match(Op0, m_ZExt(m_Value(X)))) {
+ if (match(Op0, m_OneUse(m_ZExt(m_Value(X))))) {
unsigned SrcWidth = X->getType()->getScalarSizeInBits();
if (ShAmt < SrcWidth &&
MaskedValueIsZero(X, APInt::getHighBitsSet(SrcWidth, ShAmt), 0, &I))
; CHECK-NEXT: [[AND:%.*]] = and i32 [[T:%.*]], 16777215
; CHECK-NEXT: [[EXT:%.*]] = zext i32 [[AND]] to i64
; CHECK-NEXT: call void @use(i64 [[EXT]])
-; CHECK-NEXT: [[TMP1:%.*]] = shl i32 [[T]], 8
-; CHECK-NEXT: [[SHL:%.*]] = zext i32 [[TMP1]] to i64
+; CHECK-NEXT: [[SHL:%.*]] = shl nuw nsw i64 [[EXT]], 8
; CHECK-NEXT: ret i64 [[SHL]]
;
%and = and i32 %t, 16777215