Bug 206646

Summary: if-conversion and cse
Product: Red Hat Enterprise Linux 4 Reporter: Hakon Bugge <hakon.bugge>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED WONTFIX QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 4.3CC: aostvold
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2006-09-18 18:43:37 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
C source program none

Description Hakon Bugge 2006-09-15 14:11:27 UTC
Description of problem:

Missing if-conversion. If-conversion dependent on operand order. Inconsistent 
if-conversion.

Four ways of coding a conditional assignment yields 1 conditional move using 
gcc 3.4.5 20051201 (Red Hat 3.4.5-2). gcc 4.0.2 20051130 (Red Hat 4.0.2-14.EL4) 
produces node. INHO four cmov's should have been produced. I do not see why all 
four functions generates the exact same code.

All recent new commercial compilers tested generates four cmov's:
 - intel 8.1, 9.0, and 9.1
 - pgi 5.2, 6.0, 6.1, and 6.2
 - pathscale 2.1, 2.2, 2.3, 2.4


Version-Release number of selected component (if applicable):


How reproducible:
allways


Steps to Reproduce:
gcc -O2 -S if_conversion.c;egrep cmov\|^[a-d]: if_conversion.s

  
Actual results:
a:
b:
c:
d:
        cmove   %ecx, %esi


Expected results:

One cmovX per function, four in total.

Additional info:

Comment 1 Hakon Bugge 2006-09-15 14:11:27 UTC
Created attachment 136360 [details]
C source program

Comment 2 Jakub Jelinek 2006-09-18 18:43:37 UTC
And is that actually faster?  AFAIK e.g. on Nocona cmov* is horribly slow.
Anyway, this is something that definitely won't be changed in GCC 3.4.x-RH.
GCC 4.1.x-RH and 4.2.0 (current GCC development) generate no cmov*s at all, but
if proven that it is actually faster, this would be something to consider for
GCC 4.3.0.  Can you please file it at http://gcc.gnu.org/bugzilla/?
Thanks.

Closing as WONTFIX, since this is definitely not RHEL4 material.

Comment 3 Hakon Bugge 2006-09-19 15:44:51 UTC
1) IMHO, the four routines should always produce the same code
2) Its hard to measure this, if gcc is unable to produce cmov*s ;-)  If if-
conversion is default off, but can be turned on, its no problem measuring its 
effect. But I believe that is nt the case.
3) I will file the issue at http://gcc.gnu.org/bugzilla

Thanks, HÃ¥kon