https://bugs.llvm.org/show_bug.cgi?id=45690

            Bug ID: 45690
           Summary: Slow code (-O2) due to using jne instead of using
                    cmove
           Product: clang
           Version: 10.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangb...@nondot.org
          Reporter: levo.delel...@gmail.com
                CC: blitzrak...@gmail.com, dgre...@apple.com,
                    erik.pilking...@gmail.com, llvm-bugs@lists.llvm.org,
                    richard-l...@metafoo.co.uk

Created attachment 23403
  --> https://bugs.llvm.org/attachment.cgi?id=23403&action=edit
The test cpp file

I attached my test file. I compiled with clang -O2 test.cpp -S

I notice branching in my code when I specifically wrote it so it wouldn't
branch. It jumped over a single instruction so I replaced it with a cmove. It
appears to cut this loop time in half

95,97c95
<       jne     .LBB1_8
< # %bb.7:                                #   in Loop: Header=BB1_6 Depth=1
<       movl    %ecx, %edx
---
>       cmove   %ecx, %edx
105,107c103
<       jne     .LBB1_10
< # %bb.9:                                #   in Loop: Header=BB1_6 Depth=1
<       movl    %ecx, %edx
---
>       cmove   %ecx, %edx
115,117c111
<       jne     .LBB1_12
< # %bb.11:                               #   in Loop: Header=BB1_6 Depth=1
<       movl    %ebx, %edx
---
>       cmove   %ebx, %edx
125,127c119
<       jne     .LBB1_14
< # %bb.13:                               #   in Loop: Header=BB1_6 Depth=1
<       movl    %ecx, %edx
---
>       cmove   %ecx, %edx
135,137c127
<       jne     .LBB1_16
< # %bb.15:                               #   in Loop: Header=BB1_6 Depth=1
<       movl    %ebx, %edx
---
>       cmove   %ebx, %edx
145,147c135
<       jne     .LBB1_18
< # %bb.17:                               #   in Loop: Header=BB1_6 Depth=1
<       movl    %ecx, %edx
---
>       cmove   %ecx, %edx
155,157c143
<       jne     .LBB1_20
< # %bb.19:                               #   in Loop: Header=BB1_6 Depth=1
<       movl    %ebx, %edx
---
>       cmove   %ebx, %edx
165,167c151
<       jne     .LBB1_22
< # %bb.21:                               #   in Loop: Header=BB1_6 Depth=1
<       movl    %ecx, %edx
---
>       cmove   %ecx, %edx

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to