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