We don't want to create extra instructions, and this
could infinite loop with the proposed transform in D110170.
Instruction *TrOp;
const APInt *TrShiftAmt;
if (I.isLogicalShift() && match(Op0, m_Trunc(m_Instruction(TrOp))) &&
- match(TrOp, m_Shift(m_Value(), m_APInt(TrShiftAmt))) &&
+ match(TrOp, m_OneUse(m_Shift(m_Value(), m_APInt(TrShiftAmt)))) &&
TrShiftAmt->ult(TrOp->getType()->getScalarSizeInBits())) {
Type *SrcTy = TrOp->getType();
; CHECK-LABEL: @extra_use_on_first_shift(
; CHECK-NEXT: [[A:%.*]] = ashr i32 [[X:%.*]], 3
; CHECK-NEXT: call void @use32(i32 [[A]])
-; CHECK-NEXT: [[SH1:%.*]] = lshr i32 [[A]], 6
-; CHECK-NEXT: [[TMP1:%.*]] = trunc i32 [[SH1]] to i16
-; CHECK-NEXT: [[SH:%.*]] = and i16 [[TMP1]], 1023
+; CHECK-NEXT: [[TR:%.*]] = trunc i32 [[A]] to i16
+; CHECK-NEXT: [[SH:%.*]] = lshr i16 [[TR]], 6
; CHECK-NEXT: ret i16 [[SH]]
;
%a = ashr i32 %x, 3