1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -instsimplify -S | FileCheck %s
4 define i32 @common_sub_operand(i32 %X, i32 %Y) {
5 ; CHECK-LABEL: @common_sub_operand(
6 ; CHECK-NEXT: ret i32 [[X:%.*]]
13 define i32 @negated_operand(i32 %x) {
14 ; CHECK-LABEL: @negated_operand(
15 ; CHECK-NEXT: ret i32 0
18 %r = add i32 %negx, %x
22 define <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
26 %negx = sub <2 x i32> zeroinitializer, %x
27 %r = add <2 x i32> %x, %negx
31 define i8 @knownnegation(i8 %x, i8 %y) {
32 ; CHECK-LABEL: @knownnegation(
33 ; CHECK-NEXT: ret i8 0
41 define <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
45 %xy = sub <2 x i8> %x, %y
46 %yx = sub <2 x i8> %y, %x
47 %r = add <2 x i8> %yx, %xy