[llvm-bugs] [Bug 45690] New: Slow code (-O2) due to using jne instead of using cmove

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Apr 26 23:54:48 PDT 2020


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: unassignedclangbugs at nondot.org
          Reporter: Levo.DeLellis at gmail.com
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200427/e904c461/attachment-0001.html>


More information about the llvm-bugs mailing list