summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms/InstCombine
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2015-07-14 22:39:23 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2015-07-14 22:39:23 +0000
commit33b6f82e72f12cf74341842a689f110a98707b71 (patch)
treec3b70af4781d8bafe33d146afc3ca26093e10aaf /llvm/test/Transforms/InstCombine
parenta97ad16538415f59542f5f9cff087b8cba995365 (diff)
downloadbcm5719-llvm-33b6f82e72f12cf74341842a689f110a98707b71.tar.gz
bcm5719-llvm-33b6f82e72f12cf74341842a689f110a98707b71.zip
[InstCombine] Generalize sub of selects optimization to all BinaryOperators
This exposes further optimization opportunities if the selects are correlated. llvm-svn: 242235
Diffstat (limited to 'llvm/test/Transforms/InstCombine')
-rw-r--r--llvm/test/Transforms/InstCombine/add2.ll10
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/test/Transforms/InstCombine/add2.ll b/llvm/test/Transforms/InstCombine/add2.ll
index 1af2b0ffbf0..2fe9e8cadeb 100644
--- a/llvm/test/Transforms/InstCombine/add2.ll
+++ b/llvm/test/Transforms/InstCombine/add2.ll
@@ -395,3 +395,13 @@ define i8 @add_of_mul(i8 %x, i8 %y, i8 %z) {
%sum = add nsw i8 %mA, %mB
ret i8 %sum
}
+
+define i32 @add_of_selects(i1 %A, i32 %B) {
+ %sel0 = select i1 %A, i32 0, i32 -2
+ %sel1 = select i1 %A, i32 %B, i32 2
+ %add = add i32 %sel0, %sel1
+ ret i32 %add
+; CHECK-LABEL: @add_of_selects(
+; CHECK-NEXT: %[[sel:.*]] = select i1 %A, i32 %B, i32 0
+; CHECK-NEXT: ret i32 %[[sel]]
+}
OpenPOWER on IntegriCloud