| ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py | |
| ; RUN: opt -passes=instcombine -S < %s | FileCheck %s | |
| declare void @use(i8) | |
| define i8 @shl_sub(i8 %x) { | |
| ; CHECK-LABEL: @shl_sub( | |
| ; CHECK-NEXT: [[R:%.*]] = lshr exact i8 32, [[X:%.*]] | |
| ; CHECK-NEXT: ret i8 [[R]] | |
| ; | |
| %s = sub nuw i8 4, %x | |
| %r = shl i8 2, %s | |
| ret i8 %r | |
| } | |
| define i8 @shl_sub_maxlzero(i8 %x) { | |
| ; CHECK-LABEL: @shl_sub_maxlzero( | |
| ; CHECK-NEXT: [[R:%.*]] = lshr exact i8 -64, [[X:%.*]] | |
| ; CHECK-NEXT: ret i8 [[R]] | |
| ; | |
| %s = sub nuw i8 6, %x | |
| %r = shl i8 3, %s | |
| ret i8 %r | |
| } | |
| define i8 @shl_sub_maxlone(i8 %x) { | |
| ; CHECK-LABEL: @shl_sub_maxlone( | |
| ; CHECK-NEXT: [[R:%.*]] = ashr exact i8 -128, [[X:%.*]] | |
| ; CHECK-NEXT: ret i8 [[R]] | |
| ; | |
| %s = sub nuw i8 6, %x | |
| %r = shl i8 -2, %s | |
| ret i8 %r | |
| } | |
| define i8 @shl_sub_multiuse(i8 %x) { | |
| ; CHECK-LABEL: @shl_sub_multiuse( | |
| ; CHECK-NEXT: [[S:%.*]] = sub nuw i8 3, [[X:%.*]] | |
| ; CHECK-NEXT: call void @use(i8 [[S]]) | |
| ; CHECK-NEXT: [[R:%.*]] = lshr exact i8 16, [[X]] | |
| ; CHECK-NEXT: ret i8 [[R]] | |
| ; | |
| %s = sub nuw i8 3, %x | |
| call void @use(i8 %s) | |
| %r = shl i8 2, %s | |
| ret i8 %r | |
| } | |
| define <2 x i8> @shl_sub_vec_splat(<2 x i8> %x) { | |
| ; CHECK-LABEL: @shl_sub_vec_splat( | |
| ; CHECK-NEXT: [[R:%.*]] = lshr exact <2 x i8> splat (i8 48), [[X:%.*]] | |
| ; CHECK-NEXT: ret <2 x i8> [[R]] | |
| ; | |
| %s = sub nuw <2 x i8> <i8 4, i8 4>, %x | |
| %r = shl <2 x i8> <i8 3, i8 3>, %s | |
| ret <2 x i8> %r | |
| } | |
| define <2 x i8> @shl_sub_vec_splat_poison(<2 x i8> %x) { | |
| ; CHECK-LABEL: @shl_sub_vec_splat_poison( | |
| ; CHECK-NEXT: [[S:%.*]] = sub nuw <2 x i8> <i8 4, i8 poison>, [[X:%.*]] | |
| ; CHECK-NEXT: [[R:%.*]] = shl <2 x i8> <i8 3, i8 poison>, [[S]] | |
| ; CHECK-NEXT: ret <2 x i8> [[R]] | |
| ; | |
| %s = sub nuw <2 x i8> <i8 4, i8 poison>, %x | |
| %r = shl <2 x i8> <i8 3, i8 poison>, %s | |
| ret <2 x i8> %r | |
| } | |
| define <2 x i8> @shl_sub_vec_non_splat(<2 x i8> %x) { | |
| ; CHECK-LABEL: @shl_sub_vec_non_splat( | |
| ; CHECK-NEXT: [[S:%.*]] = sub nuw <2 x i8> <i8 4, i8 3>, [[X:%.*]] | |
| ; CHECK-NEXT: [[R:%.*]] = shl <2 x i8> <i8 3, i8 2>, [[S]] | |
| ; CHECK-NEXT: ret <2 x i8> [[R]] | |
| ; | |
| %s = sub nuw <2 x i8> <i8 4, i8 3>, %x | |
| %r = shl <2 x i8> <i8 3, i8 2>, %s | |
| ret <2 x i8> %r | |
| } | |
| define i8 @shl_sub_negative_uw(i8 %x) { | |
| ; CHECK-LABEL: @shl_sub_negative_uw( | |
| ; CHECK-NEXT: [[S:%.*]] = sub i8 4, [[X:%.*]] | |
| ; CHECK-NEXT: [[R:%.*]] = shl i8 2, [[S]] | |
| ; CHECK-NEXT: ret i8 [[R]] | |
| ; | |
| %s = sub i8 4, %x | |
| %r = shl i8 2, %s | |
| ret i8 %r | |
| } | |
| define i8 @shl_sub_negative_nolzero(i8 %x) { | |
| ; CHECK-LABEL: @shl_sub_negative_nolzero( | |
| ; CHECK-NEXT: [[S:%.*]] = sub nuw i8 7, [[X:%.*]] | |
| ; CHECK-NEXT: [[R:%.*]] = shl i8 2, [[S]] | |
| ; CHECK-NEXT: ret i8 [[R]] | |
| ; | |
| %s = sub nuw i8 7, %x | |
| %r = shl i8 2, %s | |
| ret i8 %r | |
| } | |
| define i8 @shl_sub_negative_nolone(i8 %x) { | |
| ; CHECK-LABEL: @shl_sub_negative_nolone( | |
| ; CHECK-NEXT: [[S:%.*]] = sub nuw i8 7, [[X:%.*]] | |
| ; CHECK-NEXT: [[R:%.*]] = shl i8 -2, [[S]] | |
| ; CHECK-NEXT: ret i8 [[R]] | |
| ; | |
| %s = sub nuw i8 7, %x | |
| %r = shl i8 -2, %s | |
| ret i8 %r | |
| } | |
| define i8 @shl_xor(i8 %x) { | |
| ; CHECK-LABEL: @shl_xor( | |
| ; CHECK-NEXT: [[M:%.*]] = and i8 [[X:%.*]], 3 | |
| ; CHECK-NEXT: [[R:%.*]] = lshr exact i8 16, [[M]] | |
| ; CHECK-NEXT: ret i8 [[R]] | |
| ; | |
| %m = and i8 %x, 3 | |
| %s = xor i8 %m, 3 | |
| %r = shl i8 2, %s | |
| ret i8 %r | |
| } | |
| define i16 @shl_xor_i2(i2 %x) { | |
| ; CHECK-LABEL: @shl_xor_i2( | |
| ; CHECK-NEXT: [[M:%.*]] = zext i2 [[X:%.*]] to i16 | |
| ; CHECK-NEXT: [[R:%.*]] = lshr exact i16 256, [[M]] | |
| ; CHECK-NEXT: ret i16 [[R]] | |
| ; | |
| %m = zext i2 %x to i16 | |
| %s = xor i16 %m, 7 | |
| %r = shl i16 2, %s | |
| ret i16 %r | |
| } | |
| define i8 @shl_xor_notmask(i8 %x) { | |
| ; CHECK-LABEL: @shl_xor_notmask( | |
| ; CHECK-NEXT: [[M:%.*]] = and i8 [[X:%.*]], 2 | |
| ; CHECK-NEXT: [[R:%.*]] = lshr exact i8 -128, [[M]] | |
| ; CHECK-NEXT: ret i8 [[R]] | |
| ; | |
| %m = and i8 %x, 2 | |
| %s = xor i8 %m, 6 | |
| %r = shl i8 2, %s | |
| ret i8 %r | |
| } | |
| define i8 @shl_xor_multiuse(i8 %x) { | |
| ; CHECK-LABEL: @shl_xor_multiuse( | |
| ; CHECK-NEXT: [[M:%.*]] = and i8 [[X:%.*]], 3 | |
| ; CHECK-NEXT: [[S:%.*]] = xor i8 [[M]], 3 | |
| ; CHECK-NEXT: call void @use(i8 [[S]]) | |
| ; CHECK-NEXT: [[R:%.*]] = lshr exact i8 16, [[M]] | |
| ; CHECK-NEXT: ret i8 [[R]] | |
| ; | |
| %m = and i8 %x, 3 | |
| %s = xor i8 %m, 3 | |
| call void @use(i8 %s) | |
| %r = shl i8 2, %s | |
| ret i8 %r | |
| } | |
| define <2 x i8> @shl_xor_vec_splat(<2 x i8> %x) { | |
| ; CHECK-LABEL: @shl_xor_vec_splat( | |
| ; CHECK-NEXT: [[M:%.*]] = and <2 x i8> [[X:%.*]], splat (i8 3) | |
| ; CHECK-NEXT: [[R:%.*]] = lshr exact <2 x i8> splat (i8 40), [[M]] | |
| ; CHECK-NEXT: ret <2 x i8> [[R]] | |
| ; | |
| %m = and <2 x i8> <i8 3, i8 3>, %x | |
| %s = xor <2 x i8> <i8 3, i8 3>, %m | |
| %r = shl <2 x i8> <i8 5, i8 5>, %s | |
| ret <2 x i8> %r | |
| } | |
| define <2 x i8> @shl_xor_vec_splat_poison(<2 x i8> %x) { | |
| ; CHECK-LABEL: @shl_xor_vec_splat_poison( | |
| ; CHECK-NEXT: [[M:%.*]] = and <2 x i8> [[X:%.*]], splat (i8 3) | |
| ; CHECK-NEXT: [[S:%.*]] = xor <2 x i8> [[M]], <i8 poison, i8 3> | |
| ; CHECK-NEXT: [[R:%.*]] = shl nuw nsw <2 x i8> splat (i8 5), [[S]] | |
| ; CHECK-NEXT: ret <2 x i8> [[R]] | |
| ; | |
| %m = and <2 x i8> <i8 3, i8 3>, %x | |
| %s = xor <2 x i8> <i8 poison, i8 3>, %m | |
| %r = shl <2 x i8> <i8 5, i8 5>, %s | |
| ret <2 x i8> %r | |
| } | |
| define <2 x i8> @shl_xor_vec_non_splat(<2 x i8> %x) { | |
| ; CHECK-LABEL: @shl_xor_vec_non_splat( | |
| ; CHECK-NEXT: [[M:%.*]] = and <2 x i8> [[X:%.*]], splat (i8 3) | |
| ; CHECK-NEXT: [[S:%.*]] = xor <2 x i8> [[M]], splat (i8 3) | |
| ; CHECK-NEXT: [[R:%.*]] = shl nuw nsw <2 x i8> <i8 4, i8 5>, [[S]] | |
| ; CHECK-NEXT: ret <2 x i8> [[R]] | |
| ; | |
| %m = and <2 x i8> <i8 3, i8 3>, %x | |
| %s = xor <2 x i8> <i8 3, i8 3>, %m | |
| %r = shl <2 x i8> <i8 4, i8 5>, %s | |
| ret <2 x i8> %r | |
| } | |
| define i8 @shl_xor_negative_notsub(i8 %x) { | |
| ; CHECK-LABEL: @shl_xor_negative_notsub( | |
| ; CHECK-NEXT: [[M:%.*]] = and i8 [[X:%.*]], 3 | |
| ; CHECK-NEXT: [[S:%.*]] = xor i8 [[M]], 2 | |
| ; CHECK-NEXT: [[R:%.*]] = shl nuw nsw i8 2, [[S]] | |
| ; CHECK-NEXT: ret i8 [[R]] | |
| ; | |
| %m = and i8 %x, 3 | |
| %s = xor i8 %m, 2 | |
| %r = shl i8 2, %s | |
| ret i8 %r | |
| } | |
| define i8 @shl_xor_negative_abovemask(i8 %x) { | |
| ; CHECK-LABEL: @shl_xor_negative_abovemask( | |
| ; CHECK-NEXT: [[S:%.*]] = xor i8 [[X:%.*]], 7 | |
| ; CHECK-NEXT: [[R:%.*]] = shl i8 2, [[S]] | |
| ; CHECK-NEXT: ret i8 [[R]] | |
| ; | |
| %s = xor i8 %x, 7 | |
| %r = shl i8 2, %s | |
| ret i8 %r | |
| } | |
| define i8 @lshr_sub(i8 %x) { | |
| ; CHECK-LABEL: @lshr_sub( | |
| ; CHECK-NEXT: [[R:%.*]] = shl nuw nsw i8 6, [[X:%.*]] | |
| ; CHECK-NEXT: ret i8 [[R]] | |
| ; | |
| %s = sub nuw i8 3, %x | |
| %r = lshr i8 48, %s | |
| ret i8 %r | |
| } | |
| define i8 @lshr_sub_neg(i8 %x) { | |
| ; CHECK-LABEL: @lshr_sub_neg( | |
| ; CHECK-NEXT: [[R:%.*]] = shl nuw i8 24, [[X:%.*]] | |
| ; CHECK-NEXT: ret i8 [[R]] | |
| ; | |
| %s = sub nuw i8 3, %x | |
| %r = lshr i8 -64, %s | |
| ret i8 %r | |
| } | |
| define i8 @lshr_sub_maxtzero(i8 %x) { | |
| ; CHECK-LABEL: @lshr_sub_maxtzero( | |
| ; CHECK-NEXT: [[R:%.*]] = shl nuw nsw i8 1, [[X:%.*]] | |
| ; CHECK-NEXT: ret i8 [[R]] | |
| ; | |
| %s = sub nuw i8 5, %x | |
| %r = lshr i8 32, %s | |
| ret i8 %r | |
| } | |
| define i8 @lshr_sub_multiuse(i8 %x) { | |
| ; CHECK-LABEL: @lshr_sub_multiuse( | |
| ; CHECK-NEXT: [[S:%.*]] = sub nuw i8 3, [[X:%.*]] | |
| ; CHECK-NEXT: call void @use(i8 [[S]]) | |
| ; CHECK-NEXT: [[R:%.*]] = shl nuw nsw i8 4, [[X]] | |
| ; CHECK-NEXT: ret i8 [[R]] | |
| ; | |
| %s = sub nuw i8 3, %x | |
| call void @use(i8 %s) | |
| %r = lshr i8 32, %s | |
| ret i8 %r | |
| } | |
| define <2 x i8> @lshr_sub_vec_splat(<2 x i8> %x) { | |
| ; CHECK-LABEL: @lshr_sub_vec_splat( | |
| ; CHECK-NEXT: [[R:%.*]] = shl nuw nsw <2 x i8> splat (i8 4), [[X:%.*]] | |
| ; CHECK-NEXT: ret <2 x i8> [[R]] | |
| ; | |
| %s = sub nuw <2 x i8> <i8 4, i8 4>, %x | |
| %r = lshr <2 x i8> <i8 64, i8 64>, %s | |
| ret <2 x i8> %r | |
| } | |
| define <2 x i8> @lshr_sub_vec_splat_poison(<2 x i8> %x) { | |
| ; CHECK-LABEL: @lshr_sub_vec_splat_poison( | |
| ; CHECK-NEXT: [[S:%.*]] = sub nuw <2 x i8> <i8 4, i8 poison>, [[X:%.*]] | |
| ; CHECK-NEXT: [[R:%.*]] = lshr <2 x i8> <i8 64, i8 poison>, [[S]] | |
| ; CHECK-NEXT: ret <2 x i8> [[R]] | |
| ; | |
| %s = sub nuw <2 x i8> <i8 4, i8 poison>, %x | |
| %r = lshr <2 x i8> <i8 64, i8 poison>, %s | |
| ret <2 x i8> %r | |
| } | |
| define <2 x i8> @lshr_sub_vec_non_splat(<2 x i8> %x) { | |
| ; CHECK-LABEL: @lshr_sub_vec_non_splat( | |
| ; CHECK-NEXT: [[S:%.*]] = sub nuw <2 x i8> <i8 4, i8 1>, [[X:%.*]] | |
| ; CHECK-NEXT: [[R:%.*]] = lshr <2 x i8> splat (i8 64), [[S]] | |
| ; CHECK-NEXT: ret <2 x i8> [[R]] | |
| ; | |
| %s = sub nuw <2 x i8> <i8 4, i8 1>, %x | |
| %r = lshr <2 x i8> <i8 64, i8 64>, %s | |
| ret <2 x i8> %r | |
| } | |
| define i8 @lshr_sub_negative_uw(i8 %x) { | |
| ; CHECK-LABEL: @lshr_sub_negative_uw( | |
| ; CHECK-NEXT: [[S:%.*]] = sub i8 3, [[X:%.*]] | |
| ; CHECK-NEXT: [[R:%.*]] = lshr i8 32, [[S]] | |
| ; CHECK-NEXT: ret i8 [[R]] | |
| ; | |
| %s = sub i8 3, %x | |
| %r = lshr i8 32, %s | |
| ret i8 %r | |
| } | |
| define i8 @lshr_sub_negative_notrzero(i8 %x) { | |
| ; CHECK-LABEL: @lshr_sub_negative_notrzero( | |
| ; CHECK-NEXT: [[S:%.*]] = sub nuw i8 5, [[X:%.*]] | |
| ; CHECK-NEXT: [[R:%.*]] = lshr i8 16, [[S]] | |
| ; CHECK-NEXT: ret i8 [[R]] | |
| ; | |
| %s = sub nuw i8 5, %x | |
| %r = lshr i8 16, %s | |
| ret i8 %r | |
| } | |
| define i8 @lshr_xor(i8 %x) { | |
| ; CHECK-LABEL: @lshr_xor( | |
| ; CHECK-NEXT: [[M:%.*]] = and i8 [[X:%.*]], 6 | |
| ; CHECK-NEXT: [[R:%.*]] = shl nuw nsw i8 1, [[M]] | |
| ; CHECK-NEXT: ret i8 [[R]] | |
| ; | |
| %m = and i8 %x, 6 | |
| %s = xor i8 %m, 7 | |
| %r = lshr i8 -128, %s | |
| ret i8 %r | |
| } | |
| define i8 @lshr_xor_neg(i8 %x) { | |
| ; CHECK-LABEL: @lshr_xor_neg( | |
| ; CHECK-NEXT: [[M:%.*]] = and i8 [[X:%.*]], 3 | |
| ; CHECK-NEXT: [[R:%.*]] = shl nuw i8 28, [[M]] | |
| ; CHECK-NEXT: ret i8 [[R]] | |
| ; | |
| %m = and i8 %x, 3 | |
| %s = xor i8 %m, 3 | |
| %r = lshr i8 -32, %s | |
| ret i8 %r | |
| } | |
| define i8 @lshr_xor_multiuse(i8 %x) { | |
| ; CHECK-LABEL: @lshr_xor_multiuse( | |
| ; CHECK-NEXT: [[M:%.*]] = and i8 [[X:%.*]], 6 | |
| ; CHECK-NEXT: [[S:%.*]] = xor i8 [[M]], 7 | |
| ; CHECK-NEXT: call void @use(i8 [[S]]) | |
| ; CHECK-NEXT: [[R:%.*]] = shl nuw nsw i8 1, [[M]] | |
| ; CHECK-NEXT: ret i8 [[R]] | |
| ; | |
| %m = and i8 %x, 6 | |
| %s = xor i8 %m, 7 | |
| call void @use(i8 %s) | |
| %r = lshr i8 -128, %s | |
| ret i8 %r | |
| } | |
| define <2 x i8> @lshr_xor_vec_splat(<2 x i8> %x) { | |
| ; CHECK-LABEL: @lshr_xor_vec_splat( | |
| ; CHECK-NEXT: [[M:%.*]] = and <2 x i8> [[X:%.*]], <i8 2, i8 3> | |
| ; CHECK-NEXT: [[R:%.*]] = shl nuw nsw <2 x i8> splat (i8 2), [[M]] | |
| ; CHECK-NEXT: ret <2 x i8> [[R]] | |
| ; | |
| %m = and <2 x i8> <i8 2, i8 3>, %x | |
| %s = xor <2 x i8> %m, <i8 3, i8 3> | |
| %r = lshr <2 x i8> <i8 16, i8 16>, %s | |
| ret <2 x i8> %r | |
| } | |
| define <2 x i8> @lshr_xor_vec_splat_poison(<2 x i8> %x) { | |
| ; CHECK-LABEL: @lshr_xor_vec_splat_poison( | |
| ; CHECK-NEXT: [[M:%.*]] = and <2 x i8> [[X:%.*]], <i8 2, i8 3> | |
| ; CHECK-NEXT: [[S:%.*]] = xor <2 x i8> [[M]], splat (i8 3) | |
| ; CHECK-NEXT: [[R:%.*]] = lshr exact <2 x i8> <i8 poison, i8 16>, [[S]] | |
| ; CHECK-NEXT: ret <2 x i8> [[R]] | |
| ; | |
| %m = and <2 x i8> <i8 2, i8 3>, %x | |
| %s = xor <2 x i8> %m, <i8 3, i8 3> | |
| %r = lshr <2 x i8> <i8 poison, i8 16>, %s | |
| ret <2 x i8> %r | |
| } | |
| define <2 x i8> @lshr_xor_vec_non_splat(<2 x i8> %x) { | |
| ; CHECK-LABEL: @lshr_xor_vec_non_splat( | |
| ; CHECK-NEXT: [[M:%.*]] = and <2 x i8> [[X:%.*]], splat (i8 3) | |
| ; CHECK-NEXT: [[S:%.*]] = xor <2 x i8> [[M]], splat (i8 3) | |
| ; CHECK-NEXT: [[R:%.*]] = lshr exact <2 x i8> <i8 32, i8 16>, [[S]] | |
| ; CHECK-NEXT: ret <2 x i8> [[R]] | |
| ; | |
| %m = and <2 x i8> <i8 3, i8 3>, %x | |
| %s = xor <2 x i8> %m, <i8 3, i8 3> | |
| %r = lshr <2 x i8> <i8 32, i8 16>, %s | |
| ret <2 x i8> %r | |
| } | |
| define i8 @lshr_xor_negative_notsub(i8 %x) { | |
| ; CHECK-LABEL: @lshr_xor_negative_notsub( | |
| ; CHECK-NEXT: [[M:%.*]] = and i8 [[X:%.*]], 3 | |
| ; CHECK-NEXT: [[S:%.*]] = xor i8 [[M]], 2 | |
| ; CHECK-NEXT: [[R:%.*]] = lshr exact i8 96, [[S]] | |
| ; CHECK-NEXT: ret i8 [[R]] | |
| ; | |
| %m = and i8 %x, 3 | |
| %s = xor i8 %m, 2 | |
| %r = lshr i8 96, %s | |
| ret i8 %r | |
| } | |
| define i8 @lshr_xor_negative_notrzero(i8 %x) { | |
| ; CHECK-LABEL: @lshr_xor_negative_notrzero( | |
| ; CHECK-NEXT: [[M:%.*]] = and i8 [[X:%.*]], 3 | |
| ; CHECK-NEXT: [[S:%.*]] = xor i8 [[M]], 3 | |
| ; CHECK-NEXT: [[R:%.*]] = lshr i8 68, [[S]] | |
| ; CHECK-NEXT: ret i8 [[R]] | |
| ; | |
| %m = and i8 %x, 3 | |
| %s = xor i8 %m, 3 | |
| %r = lshr i8 68, %s | |
| ret i8 %r | |
| } | |
| define i8 @ashr_sub(i8 %x) { | |
| ; CHECK-LABEL: @ashr_sub( | |
| ; CHECK-NEXT: [[R:%.*]] = shl nsw i8 -8, [[X:%.*]] | |
| ; CHECK-NEXT: ret i8 [[R]] | |
| ; | |
| %s = sub nuw i8 3, %x | |
| %r = ashr i8 -64, %s | |
| ret i8 %r | |
| } | |
| define i8 @ashr_sub_maxtzero(i8 %x) { | |
| ; CHECK-LABEL: @ashr_sub_maxtzero( | |
| ; CHECK-NEXT: [[R:%.*]] = shl nsw i8 -1, [[X:%.*]] | |
| ; CHECK-NEXT: ret i8 [[R]] | |
| ; | |
| %s = sub nuw i8 6, %x | |
| %r = ashr i8 -64, %s | |
| ret i8 %r | |
| } | |
| define i8 @ashr_sub_multiuse(i8 %x) { | |
| ; CHECK-LABEL: @ashr_sub_multiuse( | |
| ; CHECK-NEXT: [[S:%.*]] = sub nuw i8 3, [[X:%.*]] | |
| ; CHECK-NEXT: call void @use(i8 [[S]]) | |
| ; CHECK-NEXT: [[R:%.*]] = shl nuw nsw i8 12, [[X]] | |
| ; CHECK-NEXT: ret i8 [[R]] | |
| ; | |
| %s = sub nuw i8 3, %x | |
| call void @use(i8 %s) | |
| %r = ashr i8 -160, %s | |
| ret i8 %r | |
| } | |
| define <2 x i8> @ashr_sub_vec_splat(<2 x i8> %x) { | |
| ; CHECK-LABEL: @ashr_sub_vec_splat( | |
| ; CHECK-NEXT: [[R:%.*]] = shl nsw <2 x i8> splat (i8 -4), [[X:%.*]] | |
| ; CHECK-NEXT: ret <2 x i8> [[R]] | |
| ; | |
| %s = sub nuw <2 x i8> <i8 4, i8 4>, %x | |
| %r = ashr <2 x i8> <i8 -64, i8 -64>, %s | |
| ret <2 x i8> %r | |
| } | |
| define <2 x i8> @ashr_sub_vec_splat_poison(<2 x i8> %x) { | |
| ; CHECK-LABEL: @ashr_sub_vec_splat_poison( | |
| ; CHECK-NEXT: [[S:%.*]] = sub nuw <2 x i8> <i8 4, i8 poison>, [[X:%.*]] | |
| ; CHECK-NEXT: [[R:%.*]] = ashr <2 x i8> splat (i8 -64), [[S]] | |
| ; CHECK-NEXT: ret <2 x i8> [[R]] | |
| ; | |
| %s = sub nuw <2 x i8> <i8 4, i8 poison>, %x | |
| %r = ashr <2 x i8> <i8 -64, i8 -64>, %s | |
| ret <2 x i8> %r | |
| } | |
| define <2 x i8> @ashr_sub_vec_non_splat(<2 x i8> %x) { | |
| ; CHECK-LABEL: @ashr_sub_vec_non_splat( | |
| ; CHECK-NEXT: [[S:%.*]] = sub nuw <2 x i8> splat (i8 4), [[X:%.*]] | |
| ; CHECK-NEXT: [[R:%.*]] = ashr <2 x i8> <i8 64, i8 -64>, [[S]] | |
| ; CHECK-NEXT: ret <2 x i8> [[R]] | |
| ; | |
| %s = sub nuw <2 x i8> <i8 4, i8 4>, %x | |
| %r = ashr <2 x i8> <i8 64, i8 -64>, %s | |
| ret <2 x i8> %r | |
| } | |
| define i8 @ashr_sub_negative_notrzero(i8 %x) { | |
| ; CHECK-LABEL: @ashr_sub_negative_notrzero( | |
| ; CHECK-NEXT: [[S:%.*]] = sub nuw i8 7, [[X:%.*]] | |
| ; CHECK-NEXT: [[R:%.*]] = ashr i8 -64, [[S]] | |
| ; CHECK-NEXT: ret i8 [[R]] | |
| ; | |
| %s = sub nuw i8 7, %x | |
| %r = ashr i8 -64, %s | |
| ret i8 %r | |
| } | |
| define i8 @ashr_xor(i8 %x) { | |
| ; CHECK-LABEL: @ashr_xor( | |
| ; CHECK-NEXT: [[S:%.*]] = xor i8 [[X:%.*]], 3 | |
| ; CHECK-NEXT: [[R:%.*]] = ashr i8 -64, [[S]] | |
| ; CHECK-NEXT: ret i8 [[R]] | |
| ; | |
| %m = and i8 %x, 3 | |
| %s = xor i8 %x, 3 | |
| %r = ashr i8 -64, %s | |
| ret i8 %r | |
| } |