diff --git a/llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp b/llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp --- a/llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp +++ b/llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp @@ -860,6 +860,7 @@ break; case Instruction::Add: case Instruction::Sub: + case Instruction::Mul: BBChanged |= processBinOp(cast(II), LVI); break; case Instruction::And: diff --git a/llvm/test/Transforms/CorrelatedValuePropagation/mul.ll b/llvm/test/Transforms/CorrelatedValuePropagation/mul.ll --- a/llvm/test/Transforms/CorrelatedValuePropagation/mul.ll +++ b/llvm/test/Transforms/CorrelatedValuePropagation/mul.ll @@ -7,7 +7,7 @@ ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i8 [[A:%.*]], 3 ; CHECK-NEXT: br i1 [[CMP]], label [[BB:%.*]], label [[EXIT:%.*]] ; CHECK: bb: -; CHECK-NEXT: [[MUL:%.*]] = mul i8 [[A]], 50 +; CHECK-NEXT: [[MUL:%.*]] = mul nuw nsw i8 [[A]], 50 ; CHECK-NEXT: ret i8 [[MUL]] ; CHECK: exit: ; CHECK-NEXT: ret i8 0 @@ -30,7 +30,7 @@ ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i8 [[A:%.*]], 4 ; CHECK-NEXT: br i1 [[CMP]], label [[BB:%.*]], label [[EXIT:%.*]] ; CHECK: bb: -; CHECK-NEXT: [[MUL:%.*]] = mul i8 [[A]], 50 +; CHECK-NEXT: [[MUL:%.*]] = mul nuw i8 [[A]], 50 ; CHECK-NEXT: ret i8 [[MUL]] ; CHECK: exit: ; CHECK-NEXT: ret i8 0 @@ -53,7 +53,7 @@ ; CHECK-NEXT: [[CMP:%.*]] = icmp ult i8 [[A:%.*]], 6 ; CHECK-NEXT: br i1 [[CMP]], label [[BB:%.*]], label [[EXIT:%.*]] ; CHECK: bb: -; CHECK-NEXT: [[MUL:%.*]] = mul i8 [[A]], 50 +; CHECK-NEXT: [[MUL:%.*]] = mul nuw i8 [[A]], 50 ; CHECK-NEXT: ret i8 [[MUL]] ; CHECK: exit: ; CHECK-NEXT: ret i8 0 @@ -101,7 +101,7 @@ ; CHECK-NEXT: [[COND:%.*]] = and i1 [[CMP1]], [[CMP2]] ; CHECK-NEXT: br i1 [[COND]], label [[BB:%.*]], label [[EXIT:%.*]] ; CHECK: bb: -; CHECK-NEXT: [[MUL:%.*]] = mul i8 [[A]], 50 +; CHECK-NEXT: [[MUL:%.*]] = mul nsw i8 [[A]], 50 ; CHECK-NEXT: ret i8 [[MUL]] ; CHECK: exit: ; CHECK-NEXT: ret i8 0