summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
authorPablo Barrio <pablo.barrio@arm.com>2016-10-24 13:04:45 +0000
committerPablo Barrio <pablo.barrio@arm.com>2016-10-24 13:04:45 +0000
commitf9e0d0b7d0217f91389ea8ecb91edc47c081d710 (patch)
treec2d734e1399bcd75d66a319637060ddb059f792b /llvm/test
parent16706dcbd42e868f4605e661df15207217e95e4a (diff)
downloadbcm5719-llvm-f9e0d0b7d0217f91389ea8ecb91edc47c081d710.tar.gz
bcm5719-llvm-f9e0d0b7d0217f91389ea8ecb91edc47c081d710.zip
[JumpThreading] Unfold selects that depend on the same condition
Summary: These are good candidates for jump threading. This enables later opts (such as InstCombine) to combine instructions from the selects with instructions out of the selects. SimplifyCFG will fold the select again if unfolding wasn't worth it. Patch by James Molloy and Pablo Barrio. Reviewers: reames, bkramer, mcrosier, gberry, haicheng, jmolloy, sebpop Subscribers: jojo, rengolin, llvm-commits Differential Revision: https://reviews.llvm.org/D25477 llvm-svn: 284971
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/Transforms/JumpThreading/unfold-selects-same-cond.ll23
1 files changed, 23 insertions, 0 deletions
diff --git a/llvm/test/Transforms/JumpThreading/unfold-selects-same-cond.ll b/llvm/test/Transforms/JumpThreading/unfold-selects-same-cond.ll
new file mode 100644
index 00000000000..12aee106bb4
--- /dev/null
+++ b/llvm/test/Transforms/JumpThreading/unfold-selects-same-cond.ll
@@ -0,0 +1,23 @@
+; RUN: opt < %s -jump-threading -instcombine -simplifycfg -S | FileCheck %s
+
+; The three selects are jump-threaded so that instcombine can optimize, and
+; simplifycfg should turn the result into a single select.
+define i32 @f(i32 %a, i32 %b) {
+; CHECK: select
+; CHECK-NOT: select
+entry:
+ %0 = and i32 %a, 1
+ %1 = and i32 %b, 1
+ %xor = xor i32 %1, %a
+ %shr32 = lshr i32 %a, 1
+ %cmp10 = icmp eq i32 %xor, 1
+ %2 = xor i32 %b, 12345
+ %b.addr.1 = select i1 %cmp10, i32 %2, i32 %b
+ %shr1633 = lshr i32 %b.addr.1, 1
+ %3 = or i32 %shr1633, 54321
+ %b.addr.2 = select i1 %cmp10, i32 %3, i32 %shr1633
+ %shr1634 = lshr i32 %b.addr.2, 2
+ %4 = or i32 %shr1634, 54320
+ %b.addr.3 = select i1 %cmp10, i32 %4, i32 %shr1634
+ ret i32 %b.addr.3
+}
OpenPOWER on IntegriCloud