forked from OSchip/llvm-project
[InstCombine] add use check to shl transform
This bug was introduced with the refactoring in:
9075edc89b
...but there were no tests to detect it.
This commit is contained in:
parent
d992950078
commit
623f93ed1c
|
@ -860,7 +860,7 @@ Instruction *InstCombinerImpl::visitShl(BinaryOperator &I) {
|
|||
// we have confidence that the shifts will get folded together.
|
||||
Instruction *TrOp;
|
||||
const APInt *TrShiftAmt;
|
||||
if (match(Op0, m_Trunc(m_Instruction(TrOp))) &&
|
||||
if (match(Op0, m_OneUse(m_Trunc(m_Instruction(TrOp)))) &&
|
||||
match(TrOp, m_OneUse(m_Shift(m_Value(), m_APInt(TrShiftAmt)))) &&
|
||||
TrShiftAmt->ult(TrOp->getType()->getScalarSizeInBits())) {
|
||||
Type *SrcTy = TrOp->getType();
|
||||
|
|
|
@ -198,8 +198,7 @@ define i8 @shl_trunc_bigger_lshr_use2(i32 %x) {
|
|||
; CHECK-NEXT: [[RT:%.*]] = lshr i32 [[X:%.*]], 5
|
||||
; CHECK-NEXT: [[TR:%.*]] = trunc i32 [[RT]] to i8
|
||||
; CHECK-NEXT: call void @use8(i8 [[TR]])
|
||||
; CHECK-NEXT: [[LT1:%.*]] = shl nuw nsw i32 [[RT]], 3
|
||||
; CHECK-NEXT: [[LT:%.*]] = trunc i32 [[LT1]] to i8
|
||||
; CHECK-NEXT: [[LT:%.*]] = shl i8 [[TR]], 3
|
||||
; CHECK-NEXT: ret i8 [[LT]]
|
||||
;
|
||||
%rt = lshr i32 %x, 5
|
||||
|
@ -214,8 +213,7 @@ define i8 @shl_trunc_smaller_lshr_use2(i32 %x) {
|
|||
; CHECK-NEXT: [[RT:%.*]] = lshr i32 [[X:%.*]], 3
|
||||
; CHECK-NEXT: [[TR:%.*]] = trunc i32 [[RT]] to i8
|
||||
; CHECK-NEXT: call void @use8(i8 [[TR]])
|
||||
; CHECK-NEXT: [[LT1:%.*]] = shl i32 [[RT]], 5
|
||||
; CHECK-NEXT: [[LT:%.*]] = trunc i32 [[LT1]] to i8
|
||||
; CHECK-NEXT: [[LT:%.*]] = shl i8 [[TR]], 5
|
||||
; CHECK-NEXT: ret i8 [[LT]]
|
||||
;
|
||||
%rt = lshr i32 %x, 3
|
||||
|
|
Loading…
Reference in New Issue