11698cc7eSJohannes Doerfert; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature 2e5b87727SSanjay Patel; Example input for update_test_checks (taken from test/Transforms/InstSimplify/add.ll) 3*40760060SBjorn Pettersson; RUN: opt < %s -passes=instsimplify -S | FileCheck %s 4240aff80SAlex Richardson 5240aff80SAlex Richardsondefine i32 @common_sub_operand(i32 %X, i32 %Y) { 6240aff80SAlex Richardson; CHECK-LABEL: define {{[^@]+}}@common_sub_operand 77128e647Ssstefan1; CHECK-SAME: (i32 [[X:%.*]], i32 [[Y:%.*]]) { 8be26bd55SJohannes Doerfert; CHECK-NEXT: ret i32 [[X]] 9240aff80SAlex Richardson; 10240aff80SAlex Richardson %Z = sub i32 %X, %Y 11240aff80SAlex Richardson %Q = add i32 %Z, %Y 12240aff80SAlex Richardson ret i32 %Q 13240aff80SAlex Richardson} 14240aff80SAlex Richardson 15240aff80SAlex Richardsondefine i32 @negated_operand(i32 %x) { 16240aff80SAlex Richardson; CHECK-LABEL: define {{[^@]+}}@negated_operand 177128e647Ssstefan1; CHECK-SAME: (i32 [[X:%.*]]) { 18240aff80SAlex Richardson; CHECK-NEXT: ret i32 0 19240aff80SAlex Richardson; 20240aff80SAlex Richardson %negx = sub i32 0, %x 21240aff80SAlex Richardson %r = add i32 %negx, %x 22240aff80SAlex Richardson ret i32 %r 23240aff80SAlex Richardson} 24240aff80SAlex Richardson 25240aff80SAlex Richardsondefine <2 x i32> @negated_operand_commute_vec(<2 x i32> %x) { 26240aff80SAlex Richardson; CHECK-LABEL: define {{[^@]+}}@negated_operand_commute_vec 277128e647Ssstefan1; CHECK-SAME: (<2 x i32> [[X:%.*]]) { 28240aff80SAlex Richardson; CHECK-NEXT: ret <2 x i32> zeroinitializer 29240aff80SAlex Richardson; 30240aff80SAlex Richardson %negx = sub <2 x i32> zeroinitializer, %x 31240aff80SAlex Richardson %r = add <2 x i32> %x, %negx 32240aff80SAlex Richardson ret <2 x i32> %r 33240aff80SAlex Richardson} 34240aff80SAlex Richardson 35240aff80SAlex Richardsondefine i8 @knownnegation(i8 %x, i8 %y) { 36240aff80SAlex Richardson; CHECK-LABEL: define {{[^@]+}}@knownnegation 377128e647Ssstefan1; CHECK-SAME: (i8 [[X:%.*]], i8 [[Y:%.*]]) { 38240aff80SAlex Richardson; CHECK-NEXT: ret i8 0 39240aff80SAlex Richardson; 40240aff80SAlex Richardson %xy = sub i8 %x, %y 41240aff80SAlex Richardson %yx = sub i8 %y, %x 42240aff80SAlex Richardson %r = add i8 %xy, %yx 43240aff80SAlex Richardson ret i8 %r 44240aff80SAlex Richardson} 45240aff80SAlex Richardson 46240aff80SAlex Richardsondefine <2 x i8> @knownnegation_commute_vec(<2 x i8> %x, <2 x i8> %y) { 47240aff80SAlex Richardson; CHECK-LABEL: define {{[^@]+}}@knownnegation_commute_vec 487128e647Ssstefan1; CHECK-SAME: (<2 x i8> [[X:%.*]], <2 x i8> [[Y:%.*]]) { 49240aff80SAlex Richardson; CHECK-NEXT: ret <2 x i8> zeroinitializer 50240aff80SAlex Richardson; 51240aff80SAlex Richardson %xy = sub <2 x i8> %x, %y 52240aff80SAlex Richardson %yx = sub <2 x i8> %y, %x 53240aff80SAlex Richardson %r = add <2 x i8> %yx, %xy 54240aff80SAlex Richardson ret <2 x i8> %r 55240aff80SAlex Richardson} 56e5b87727SSanjay Patel 57e5b87727SSanjay Pateldefine i32 @nameless_value(i32 %X) { 58e5b87727SSanjay Patel; CHECK-LABEL: define {{[^@]+}}@nameless_value 597128e647Ssstefan1; CHECK-SAME: (i32 [[X:%.*]]) { 60e5b87727SSanjay Patel; CHECK-NEXT: [[TMP1:%.*]] = sub i32 42, [[X]] 61e5b87727SSanjay Patel; CHECK-NEXT: ret i32 [[TMP1]] 62e5b87727SSanjay Patel; 63e5b87727SSanjay Patel %1 = sub i32 42, %X 64e5b87727SSanjay Patel ret i32 %1 65e5b87727SSanjay Patel} 66