Path: utzoo!mnetor!uunet!lll-winken!lll-lcc!lll-tis!ames!amdcad!tim From: tim@amdcad.AMD.COM (Tim Olson) Newsgroups: comp.lang.c Subject: Re: Bad optimizations (was Re: comma operator) Message-ID: <20060@amdcad.AMD.COM> Date: 21 Jan 88 10:10:37 GMT References: <3819@sigi.Colorado.EDU> <5080013@hpfcdc.HP.COM> <7120@brl-smoke.ARPA> <269@vsi1.UUCP> Organization: Advanced Micro Devices, Inc., Sunnyvale, Ca. Lines: 32 Keywords: optimization swap assembly C sun compiler Summary: stop doubting.... In article <269@vsi1.UUCP>, steve@vsi1.UUCP (Steve Maurer) writes: | This isn't really Sun's fault, I might add. Most compilers would do | just about the same, or perhaps worse. Of course, an extrodinarily | optimized compiler (one in which i = 5; i = 6; would delete the i = 5; | statement altogether), might approximate the original intent of the | code, but I doubt it. | | Steve Maurer Well, you can stop doubting. Here is the .s file generated by the MetaWare Am29000 compiler (minus procedure prologue and epilogue): call lr0,_foo_marker As you can see, there are no swaps whatsoever. This is because they weren't needed. I then modified the source to pass 'a' and 'b' to the function 'foo_marker', so that the values were required. The resulting code is [with foo_marker(a,b)]: const lr3,3 <-- pass '3' as second parameter call lr0,_foo_marker const lr2,5 <-- pass '5' as the first (delayed branch) ( Ain't RISC machines + optimizing compilers great! ;-) -- Tim Olson Advanced Micro Devices (tim@amdcad.amd.com)