1; RUN: opt < %s -reassociate -dce -S | FileCheck %s 2; PR12985 3 4; Verify the nsw flags are preserved when converting shl to mul. 5 6; CHECK-LABEL: @shl_to_mul_nsw( 7; CHECK: %mul = mul i32 %i, -2147483648 8; CHECK: add i32 %mul, 1 9define i32 @shl_to_mul_nsw(i32 %i) { 10entry: 11 %mul = shl nsw i32 %i, 31 12 %mul2 = add i32 %mul, 1 13 ret i32 %mul2 14} 15 16; CHECK-LABEL: @shl_to_mul_nuw( 17; CHECK: %mul = mul nuw i32 %i, 4 18; CHECK: add i32 %mul, 1 19define i32 @shl_to_mul_nuw(i32 %i) { 20entry: 21 %mul = shl nuw i32 %i, 2 22 %mul2 = add i32 %mul, 1 23 ret i32 %mul2 24} 25 26; CHECK-LABEL: @shl_to_mul_nuw_nsw( 27; CHECK: %mul = mul nuw nsw i32 %i, 4 28; CHECK: add i32 %mul, 1 29define i32 @shl_to_mul_nuw_nsw(i32 %i) { 30entry: 31 %mul = shl nuw nsw i32 %i, 2 32 %mul2 = add i32 %mul, 1 33 ret i32 %mul2 34} 35