summaryrefslogtreecommitdiffstats
path: root/llvm/test/CodeGen/X86/select_const.ll
diff options
context:
space:
mode:
authorNAKAMURA Takumi <geek4civic@gmail.com>2012-10-16 06:28:34 +0000
committerNAKAMURA Takumi <geek4civic@gmail.com>2012-10-16 06:28:34 +0000
commit1705a999fad9de3d1b0368fa9793ae3b3db44015 (patch)
tree9ffc998aec59074add71673ffaf199db80212c98 /llvm/test/CodeGen/X86/select_const.ll
parent118a78b977d79e85c7f18f6c0a4d4d229d8303e9 (diff)
downloadbcm5719-llvm-1705a999fad9de3d1b0368fa9793ae3b3db44015.tar.gz
bcm5719-llvm-1705a999fad9de3d1b0368fa9793ae3b3db44015.zip
Reapply r165661, Patch by Shuxin Yang <shuxin.llvm@gmail.com>.
Original message: The attached is the fix to radar://11663049. The optimization can be outlined by following rules: (select (x != c), e, c) -> select (x != c), e, x), (select (x == c), c, e) -> select (x == c), x, e) where the <c> is an integer constant. The reason for this change is that : on x86, conditional-move-from-constant needs two instructions; however, conditional-move-from-register need only one instruction. While the LowerSELECT() sounds to be the most convenient place for this optimization, it turns out to be a bad place. The reason is that by replacing the constant <c> with a symbolic value, it obscure some instruction-combining opportunities which would otherwise be very easy to spot. For that reason, I have to postpone the change to last instruction-combining phase. The change passes the test of "make check-all -C <build-root/test" and "make -C project/test-suite/SingleSource". Original message since r165661: My previous change has a bug: I negated the condition code of a CMOV, and go ahead creating a new CMOV using the *ORIGINAL* condition code. llvm-svn: 166017
Diffstat (limited to 'llvm/test/CodeGen/X86/select_const.ll')
-rw-r--r--llvm/test/CodeGen/X86/select_const.ll16
1 files changed, 16 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/X86/select_const.ll b/llvm/test/CodeGen/X86/select_const.ll
new file mode 100644
index 00000000000..5b2409d2396
--- /dev/null
+++ b/llvm/test/CodeGen/X86/select_const.ll
@@ -0,0 +1,16 @@
+; RUN: llc < %s -mtriple=x86_64-apple-darwin10 -mcpu=corei7 | FileCheck %s
+
+define i64 @test1(i64 %x) nounwind {
+entry:
+ %cmp = icmp eq i64 %x, 2
+ %add = add i64 %x, 1
+ %retval.0 = select i1 %cmp, i64 2, i64 %add
+ ret i64 %retval.0
+
+; CHECK: test1:
+; CHECK: leaq 1(%rdi), %rax
+; CHECK: cmpq $2, %rdi
+; CHECK: cmoveq %rdi, %rax
+; CHECK: ret
+
+}
OpenPOWER on IntegriCloud