1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; Example input for update_test_checks (taken from test/Transforms/InstSimplify/add.ll) 3; RUN: opt < %s -passes=instsimplify -S | FileCheck %s 4 5define i32 @common_sub_operand(i32 %X, i32 %Y) { 6; CHECK-LABEL: @common_sub_operand( 7; CHECK-NEXT: ret i32 [[X:%.*]] 8; 9 %Z = sub i32 %X, %Y 10 %Q = add i32 %Z, %Y 11 ret i32 %Q 12} 13 14define i32 @negated_operand(i32 %x) { 15; CHECK-LABEL: @negated_operand( 16; CHECK-NEXT: ret i32 0 17; 18 %negx = sub i32 0, %x 19 %r = add i32 %negx, %x 20 ret i32 %r 21} 22 23define <2 x i32> @negated_operand_commute_vec(<2 x i32> %x) { 24; CHECK-LABEL: @negated_operand_commute_vec( 25; CHECK-NEXT: ret <2 x i32> zeroinitializer 26; 27 %negx = sub <2 x i32> zeroinitializer, %x 28 %r = add <2 x i32> %x, %negx 29 ret <2 x i32> %r 30} 31 32define i8 @knownnegation(i8 %x, i8 %y) { 33; CHECK-LABEL: @knownnegation( 34; CHECK-NEXT: ret i8 0 35; 36 %xy = sub i8 %x, %y 37 %yx = sub i8 %y, %x 38 %r = add i8 %xy, %yx 39 ret i8 %r 40} 41 42define <2 x i8> @knownnegation_commute_vec(<2 x i8> %x, <2 x i8> %y) { 43; CHECK-LABEL: @knownnegation_commute_vec( 44; CHECK-NEXT: ret <2 x i8> zeroinitializer 45; 46 %xy = sub <2 x i8> %x, %y 47 %yx = sub <2 x i8> %y, %x 48 %r = add <2 x i8> %yx, %xy 49 ret <2 x i8> %r 50} 51 52define i32 @nameless_value(i32 %X) { 53; CHECK-LABEL: @nameless_value( 54; CHECK-NEXT: [[TMP1:%.*]] = sub i32 42, [[X:%.*]] 55; CHECK-NEXT: ret i32 [[TMP1]] 56; 57 %1 = sub i32 42, %X 58 ret i32 %1 59} 60