summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoman Lebedev <lebedev.ri@gmail.com>2018-04-26 20:07:17 +0000
committerRoman Lebedev <lebedev.ri@gmail.com>2018-04-26 20:07:17 +0000
commit7cc56f1599b990afe806ad217352502c528a828d (patch)
tree238c492bc38b5d66cccf1b4b7e4515db10f78a90
parent1efe879641848006bbb126b6bf2d25ece31b4a86 (diff)
downloadbcm5719-llvm-7cc56f1599b990afe806ad217352502c528a828d.tar.gz
bcm5719-llvm-7cc56f1599b990afe806ad217352502c528a828d.zip
[InstCombine][NFC] add2.ll: add a few commutative checks.
Fixes some missing test coverage in InstCombineAddSub.cpp, visitAdd() llvm-svn: 330986
-rw-r--r--llvm/test/Transforms/InstCombine/add2.ll33
1 files changed, 33 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/add2.ll b/llvm/test/Transforms/InstCombine/add2.ll
index 6b2073c90c6..ed99936e081 100644
--- a/llvm/test/Transforms/InstCombine/add2.ll
+++ b/llvm/test/Transforms/InstCombine/add2.ll
@@ -379,6 +379,39 @@ define i32 @add_or_and(i32 %x, i32 %y) {
ret i32 %add
}
+define i32 @add_or_and_commutative(i32 %x, i32 %y) {
+; CHECK-LABEL: @add_or_and_commutative(
+; CHECK-NEXT: [[ADD:%.*]] = add i32 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: ret i32 [[ADD]]
+;
+ %or = or i32 %x, %y
+ %and = and i32 %y, %x ; swapped
+ %add = add i32 %or, %and
+ ret i32 %add
+}
+
+define i32 @add_and_or(i32 %x, i32 %y) {
+; CHECK-LABEL: @add_and_or(
+; CHECK-NEXT: [[ADD:%.*]] = add i32 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: ret i32 [[ADD]]
+;
+ %or = or i32 %x, %y
+ %and = and i32 %x, %y
+ %add = add i32 %and, %or
+ ret i32 %add
+}
+
+define i32 @add_and_or_commutative(i32 %x, i32 %y) {
+; CHECK-LABEL: @add_and_or_commutative(
+; CHECK-NEXT: [[ADD:%.*]] = add i32 [[X:%.*]], [[Y:%.*]]
+; CHECK-NEXT: ret i32 [[ADD]]
+;
+ %or = or i32 %x, %y
+ %and = and i32 %y, %x ; swapped
+ %add = add i32 %and, %or
+ ret i32 %add
+}
+
define i32 @add_nsw_or_and(i32 %x, i32 %y) {
; CHECK-LABEL: @add_nsw_or_and(
; CHECK-NEXT: [[ADD:%.*]] = add nsw i32 [[X:%.*]], [[Y:%.*]]
OpenPOWER on IntegriCloud