[llvm] r267426 - add tests for potential CGP transform (PR27344)

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 25 09:56:52 PDT 2016


Author: spatel
Date: Mon Apr 25 11:56:52 2016
New Revision: 267426

URL: http://llvm.org/viewvc/llvm-project?rev=267426&view=rev
Log:
add tests for potential CGP transform (PR27344)

Modified:
    llvm/trunk/test/CodeGen/X86/cmov-into-branch.ll

Modified: llvm/trunk/test/CodeGen/X86/cmov-into-branch.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/cmov-into-branch.ll?rev=267426&r1=267425&r2=267426&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/cmov-into-branch.ll (original)
+++ llvm/trunk/test/CodeGen/X86/cmov-into-branch.ll Mon Apr 25 11:56:52 2016
@@ -64,3 +64,35 @@ define i32 @test5(i32 %a, i32* nocapture
   %cond5 = select i1 %cmp, i32 %cond, i32 %x
   ret i32 %cond5
 }
+
+; If a select is not obviously predictable, don't turn it into a branch.
+define i32 @weighted_select1(i32 %a, i32 %b) {
+; CHECK-LABEL: weighted_select1:
+; CHECK:       # BB#0:
+; CHECK-NEXT:    testl %edi, %edi
+; CHECK-NEXT:    cmovnel %edi, %esi
+; CHECK-NEXT:    movl %esi, %eax
+; CHECK-NEXT:    retq
+;
+  %cmp = icmp ne i32 %a, 0
+  %sel = select i1 %cmp, i32 %a, i32 %b, !prof !0
+  ret i32 %sel
+}
+
+; TODO: If a select is obviously predictable, turn it into a branch.
+define i32 @weighted_select2(i32 %a, i32 %b) {
+; CHECK-LABEL: weighted_select2:
+; CHECK:       # BB#0:
+; CHECK-NEXT:    testl %edi, %edi
+; CHECK-NEXT:    cmovnel %edi, %esi
+; CHECK-NEXT:    movl %esi, %eax
+; CHECK-NEXT:    retq
+;
+  %cmp = icmp ne i32 %a, 0
+  %sel = select i1 %cmp, i32 %a, i32 %b, !prof !1
+  ret i32 %sel
+}
+
+!0 = !{!"branch_weights", i32 1, i32 99}
+!1 = !{!"branch_weights", i32 1, i32 100}
+




More information about the llvm-commits mailing list