1a6c02281SNoah Goldstein; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 3 2a6c02281SNoah Goldstein; RUN: opt < %s -passes=instcombine -S | FileCheck %s 3a6c02281SNoah Goldsteindefine i8 @flip_add_of_shift_neg(i8 %v, i8 %sh, i8 %x) { 4a6c02281SNoah Goldstein; CHECK-LABEL: define i8 @flip_add_of_shift_neg 5a6c02281SNoah Goldstein; CHECK-SAME: (i8 [[V:%.*]], i8 [[SH:%.*]], i8 [[X:%.*]]) { 6*9c375a45SNoah Goldstein; CHECK-NEXT: [[TMP1:%.*]] = shl i8 [[V]], [[SH]] 7*9c375a45SNoah Goldstein; CHECK-NEXT: [[R:%.*]] = sub i8 [[X]], [[TMP1]] 8a6c02281SNoah Goldstein; CHECK-NEXT: ret i8 [[R]] 9a6c02281SNoah Goldstein; 10a6c02281SNoah Goldstein %nv = sub i8 0, %v 11a6c02281SNoah Goldstein %sv = shl nuw nsw i8 %nv, %sh 12a6c02281SNoah Goldstein %r = add i8 %sv, %x 13a6c02281SNoah Goldstein ret i8 %r 14a6c02281SNoah Goldstein} 15a6c02281SNoah Goldstein 16a6c02281SNoah Goldsteindefine <2 x i8> @flip_add_of_shift_neg_vec(<2 x i8> %v, <2 x i8> %sh, <2 x i8> %xx) { 17a6c02281SNoah Goldstein; CHECK-LABEL: define <2 x i8> @flip_add_of_shift_neg_vec 18a6c02281SNoah Goldstein; CHECK-SAME: (<2 x i8> [[V:%.*]], <2 x i8> [[SH:%.*]], <2 x i8> [[XX:%.*]]) { 19a6c02281SNoah Goldstein; CHECK-NEXT: [[X:%.*]] = mul <2 x i8> [[XX]], [[XX]] 20*9c375a45SNoah Goldstein; CHECK-NEXT: [[TMP1:%.*]] = shl <2 x i8> [[V]], [[SH]] 21*9c375a45SNoah Goldstein; CHECK-NEXT: [[R:%.*]] = sub <2 x i8> [[X]], [[TMP1]] 22a6c02281SNoah Goldstein; CHECK-NEXT: ret <2 x i8> [[R]] 23a6c02281SNoah Goldstein; 24a6c02281SNoah Goldstein %x = mul <2 x i8> %xx, %xx 25a6c02281SNoah Goldstein %nv = sub <2 x i8> zeroinitializer, %v 26a6c02281SNoah Goldstein %sv = shl <2 x i8> %nv, %sh 27a6c02281SNoah Goldstein %r = add <2 x i8> %x, %sv 28a6c02281SNoah Goldstein ret <2 x i8> %r 29a6c02281SNoah Goldstein} 30a6c02281SNoah Goldstein 31a6c02281SNoah Goldsteindefine i8 @flip_add_of_shift_neg_fail_shr(i8 %v, i8 %sh, i8 %x) { 32a6c02281SNoah Goldstein; CHECK-LABEL: define i8 @flip_add_of_shift_neg_fail_shr 33a6c02281SNoah Goldstein; CHECK-SAME: (i8 [[V:%.*]], i8 [[SH:%.*]], i8 [[X:%.*]]) { 34a6c02281SNoah Goldstein; CHECK-NEXT: [[NV:%.*]] = sub i8 0, [[V]] 35a6c02281SNoah Goldstein; CHECK-NEXT: [[SV:%.*]] = lshr i8 [[NV]], [[SH]] 36a6c02281SNoah Goldstein; CHECK-NEXT: [[R:%.*]] = add i8 [[SV]], [[X]] 37a6c02281SNoah Goldstein; CHECK-NEXT: ret i8 [[R]] 38a6c02281SNoah Goldstein; 39a6c02281SNoah Goldstein %nv = sub i8 0, %v 40a6c02281SNoah Goldstein %sv = lshr i8 %nv, %sh 41a6c02281SNoah Goldstein %r = add i8 %sv, %x 42a6c02281SNoah Goldstein ret i8 %r 43a6c02281SNoah Goldstein} 44a6c02281SNoah Goldstein 45a6c02281SNoah Goldsteindeclare void @use.v2i8(<2 x i8>) 46a6c02281SNoah Goldsteindefine <2 x i8> @flip_add_of_shift_neg_vec_fail_multiuse_neg(<2 x i8> %v, <2 x i8> %sh, <2 x i8> %xx) { 47a6c02281SNoah Goldstein; CHECK-LABEL: define <2 x i8> @flip_add_of_shift_neg_vec_fail_multiuse_neg 48a6c02281SNoah Goldstein; CHECK-SAME: (<2 x i8> [[V:%.*]], <2 x i8> [[SH:%.*]], <2 x i8> [[XX:%.*]]) { 49a6c02281SNoah Goldstein; CHECK-NEXT: [[X:%.*]] = mul <2 x i8> [[XX]], [[XX]] 50a6c02281SNoah Goldstein; CHECK-NEXT: [[NV:%.*]] = sub <2 x i8> zeroinitializer, [[V]] 51a6c02281SNoah Goldstein; CHECK-NEXT: [[SV:%.*]] = shl <2 x i8> [[NV]], [[SH]] 52a6c02281SNoah Goldstein; CHECK-NEXT: call void @use.v2i8(<2 x i8> [[NV]]) 53a6c02281SNoah Goldstein; CHECK-NEXT: [[R:%.*]] = add <2 x i8> [[X]], [[SV]] 54a6c02281SNoah Goldstein; CHECK-NEXT: ret <2 x i8> [[R]] 55a6c02281SNoah Goldstein; 56a6c02281SNoah Goldstein %x = mul <2 x i8> %xx, %xx 57a6c02281SNoah Goldstein %nv = sub <2 x i8> zeroinitializer, %v 58a6c02281SNoah Goldstein %sv = shl <2 x i8> %nv, %sh 59a6c02281SNoah Goldstein call void @use.v2i8(<2 x i8> %nv) 60a6c02281SNoah Goldstein %r = add <2 x i8> %x, %sv 61a6c02281SNoah Goldstein ret <2 x i8> %r 62a6c02281SNoah Goldstein} 63a6c02281SNoah Goldstein 64a6c02281SNoah Goldsteindefine <2 x i8> @flip_add_of_shift_neg_vec_fail_multiuse_shift(<2 x i8> %v, <2 x i8> %sh, <2 x i8> %xx) { 65a6c02281SNoah Goldstein; CHECK-LABEL: define <2 x i8> @flip_add_of_shift_neg_vec_fail_multiuse_shift 66a6c02281SNoah Goldstein; CHECK-SAME: (<2 x i8> [[V:%.*]], <2 x i8> [[SH:%.*]], <2 x i8> [[XX:%.*]]) { 67a6c02281SNoah Goldstein; CHECK-NEXT: [[X:%.*]] = mul <2 x i8> [[XX]], [[XX]] 68a6c02281SNoah Goldstein; CHECK-NEXT: [[NV:%.*]] = sub <2 x i8> zeroinitializer, [[V]] 69a6c02281SNoah Goldstein; CHECK-NEXT: [[SV:%.*]] = shl <2 x i8> [[NV]], [[SH]] 70a6c02281SNoah Goldstein; CHECK-NEXT: call void @use.v2i8(<2 x i8> [[SV]]) 71a6c02281SNoah Goldstein; CHECK-NEXT: [[R:%.*]] = add <2 x i8> [[X]], [[SV]] 72a6c02281SNoah Goldstein; CHECK-NEXT: ret <2 x i8> [[R]] 73a6c02281SNoah Goldstein; 74a6c02281SNoah Goldstein %x = mul <2 x i8> %xx, %xx 75a6c02281SNoah Goldstein %nv = sub <2 x i8> zeroinitializer, %v 76a6c02281SNoah Goldstein %sv = shl <2 x i8> %nv, %sh 77a6c02281SNoah Goldstein call void @use.v2i8(<2 x i8> %sv) 78a6c02281SNoah Goldstein %r = add <2 x i8> %x, %sv 79a6c02281SNoah Goldstein ret <2 x i8> %r 80a6c02281SNoah Goldstein} 81