diff --git a/llvm/test/Transforms/InstCombine/mul.ll b/llvm/test/Transforms/InstCombine/mul.ll index 8a3e793a7270b..29508e5e5d2ce 100644 --- a/llvm/test/Transforms/InstCombine/mul.ll +++ b/llvm/test/Transforms/InstCombine/mul.ll @@ -240,7 +240,7 @@ define i8 @shl1_decrement(i8 %x, i8 %y) { ret i8 %m } -define i8 @shl1_decrement_commute(i8 %x, i8 %p) { +define i8 @shl1_decrement_commute(i8 %x, i8 noundef %p) { ; CHECK-LABEL: @shl1_decrement_commute( ; CHECK-NEXT: [[Y:%.*]] = ashr i8 [[P:%.*]], 1 ; CHECK-NEXT: [[NOTMASK:%.*]] = shl nsw i8 -1, [[X:%.*]] @@ -255,6 +255,32 @@ define i8 @shl1_decrement_commute(i8 %x, i8 %p) { ret i8 %m } +define i8 @shl1_nuw_decrement(i8 %x, i8 %y) { +; CHECK-LABEL: @shl1_nuw_decrement( +; CHECK-NEXT: [[POW2X:%.*]] = shl i8 -1, [[X:%.*]] +; CHECK-NEXT: [[X1:%.*]] = xor i8 [[POW2X]], -1 +; CHECK-NEXT: [[M:%.*]] = mul nuw i8 [[X1]], [[Y:%.*]] +; CHECK-NEXT: ret i8 [[M]] +; + %pow2x = shl i8 -1, %x + %x1 = xor i8 %pow2x, -1 + %m = mul nuw i8 %x1, %y + ret i8 %m +} + +define i8 @shl1_nsw_decrement(i8 %x, i8 %y) { +; CHECK-LABEL: @shl1_nsw_decrement( +; CHECK-NEXT: [[POW2X:%.*]] = shl nsw i8 -1, [[X:%.*]] +; CHECK-NEXT: [[X1:%.*]] = xor i8 [[POW2X]], -1 +; CHECK-NEXT: [[M:%.*]] = mul nsw i8 [[X1]], [[Y:%.*]] +; CHECK-NEXT: ret i8 [[M]] +; + %pow2x = shl nsw i8 -1, %x + %x1 = xor i8 %pow2x, -1 + %m = mul nsw i8 %x1, %y + ret i8 %m +} + define i32 @shl1_decrement_use(i32 %x, i32 %y) { ; CHECK-LABEL: @shl1_decrement_use( ; CHECK-NEXT: [[NOTMASK:%.*]] = shl nsw i32 -1, [[X:%.*]]