59 lines · plain
1; Example input for update_test_checks (taken from test/Transforms/InstSimplify/add.ll)2; RUN: opt < %s -passes=instsimplify -S | FileCheck %s3 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, %Y9 %Q = add i32 %Z, %Y10 ret i32 %Q11}12 13define i32 @negated_operand(i32 %x) {14; CHECK-LABEL: @negated_operand(15; CHECK-NEXT: ret i32 016;17 %negx = sub i32 0, %x18 %r = add i32 %negx, %x19 ret i32 %r20}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> zeroinitializer25;26 %negx = sub <2 x i32> zeroinitializer, %x27 %r = add <2 x i32> %x, %negx28 ret <2 x i32> %r29}30 31define i8 @knownnegation(i8 %x, i8 %y) {32; CHECK-LABEL: @knownnegation(33; CHECK-NEXT: ret i8 034;35 %xy = sub i8 %x, %y36 %yx = sub i8 %y, %x37 %r = add i8 %xy, %yx38 ret i8 %r39}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> zeroinitializer44;45 %xy = sub <2 x i8> %x, %y46 %yx = sub <2 x i8> %y, %x47 %r = add <2 x i8> %yx, %xy48 ret <2 x i8> %r49}50 51define i32 @nameless_value(i32 %X) {52; CHECK-LABEL: @nameless_value(53; CHECK-NEXT: [[TMP1:%.*]] = sub i32 42, [[X:%.*]]54; CHECK-NEXT: ret i32 [[TMP1]]55;56 %1 = sub i32 42, %X57 ret i32 %158}59