[llvm] r355277 - Add test case for add to sub transformation. NFC
Amaury Sechet via llvm-commits
llvm-commits at lists.llvm.org
Sat Mar 2 12:12:25 PST 2019
Author: deadalnix
Date: Sat Mar 2 12:12:25 2019
New Revision: 355277
URL: http://llvm.org/viewvc/llvm-project?rev=355277&view=rev
Log:
Add test case for add to sub transformation. NFC
Modified:
llvm/trunk/test/Transforms/InstCombine/add.ll
Modified: llvm/trunk/test/Transforms/InstCombine/add.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/add.ll?rev=355277&r1=355276&r2=355277&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/add.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/add.ll Sat Mar 2 12:12:25 2019
@@ -947,3 +947,30 @@ define i32 @add_not_increment_commuted(i
ret i32 %E
}
+; E = (A + ~B) + 1 = A - B
+define i32 @add_to_sub(i32 %A, i32 %B) {
+; CHECK-LABEL: @add_to_sub(
+; CHECK-NEXT: [[C:%.*]] = xor i32 [[B:%.*]], -1
+; CHECK-NEXT: [[D:%.*]] = add i32 [[C]], [[A:%.*]]
+; CHECK-NEXT: [[E:%.*]] = add i32 [[D]], 1
+; CHECK-NEXT: ret i32 [[E]]
+;
+ %C = xor i32 %B, -1
+ %D = add i32 %A, %C
+ %E = add i32 %D, 1
+ ret i32 %E
+}
+
+; E = (~B + A) + 1 = A - B
+define i32 @add_to_sub2(i32 %A, i32 %B) {
+; CHECK-LABEL: @add_to_sub2(
+; CHECK-NEXT: [[C:%.*]] = xor i32 [[B:%.*]], -1
+; CHECK-NEXT: [[D:%.*]] = add i32 [[C]], [[A:%.*]]
+; CHECK-NEXT: [[E:%.*]] = add i32 [[D]], 1
+; CHECK-NEXT: ret i32 [[E]]
+;
+ %C = xor i32 %B, -1
+ %D = add i32 %C, %A
+ %E = add i32 %D, 1
+ ret i32 %E
+}
More information about the llvm-commits
mailing list