GCJ Optimizer troubles: testcase

Andrew Haley aph@redhat.com
Thu Aug 12 21:22:00 GMT 2004


Thomas Aeby writes:
 > On Tue, 2004年08月10日 at 22:27, Bryce McKinlay wrote:
 > > Could you post a full test case please? That behaviour would surprise 
 > > me, too.
 > 
 > Ok, here it is:
Yes, it's a bug. Confirmed in gcc 3.4.0, OK in mainline.
The Initial RTL is broken. Note that insn 18 is a jump around the
code that increments "value". If compiled with -O0, the initial RTL
is correct.
This means that some optimization which happens before RTL generation
is causing the problem. There aren't many optimizations which happen
so early.
Andrew.
(call_insn 9 8 10 (set (reg:SI 0 ax)
 (call (mem:QI (symbol_ref:SI ("_Jv_MonitorEnter") [flags 0x41] <function_decl 0x403884a4 _Jv_MonitorEnter>) [0 S1 A8])
 (const_int 4 [0x4]))) -1 (nil)
 (nil)
 (nil))
(note 10 9 11 NOTE_INSN_DELETED)
(note 11 10 12 NOTE_INSN_DELETED)
(note 12 11 13 1 NOTE_INSN_EH_REGION_BEG)
(note 13 12 17 NOTE_INSN_DELETED)
(note 17 13 18 1 NOTE_INSN_EH_REGION_END)
(jump_insn 18 17 19 (set (pc)
 (label_ref 30)) -1 (nil)
 (nil))
(barrier 19 18 20)
(code_label 20 19 21 3 "" [0 uses])
(insn 21 20 22 (set (reg:SI 61)
 (reg:SI 62)) -1 (nil)
 (nil))
(insn 22 21 23 (set (reg:SI 63)
 (reg:SI 64)) -1 (nil)
 (nil))
(insn 23 22 14 (set (mem/f:SI (reg/f:SI 56 virtual-outgoing-args) [0 S4 A32])
 (reg/v/f:SI 58 [ this ])) -1 (nil)
 (nil))
(insn 14 23 15 (set (reg:SI 60)
 (mem/s/j:SI (plus:SI (reg/v/f:SI 58 [ this ])
 (const_int 4 [0x4])) [0 <variable>.value+0 S4 A32])) -1 (nil)
 (nil))
(insn 15 14 16 (parallel [
 (set (reg:SI 59)
 (plus:SI (reg:SI 60)
 (const_int 1 [0x1])))
 (clobber (reg:CC 17 flags))
 ]) -1 (nil)
 (nil))
(insn 16 15 24 (set (mem/s/j:SI (plus:SI (reg/v/f:SI 58 [ this ])
 (const_int 4 [0x4])) [0 <variable>.value+0 S4 A32])
 (reg:SI 59)) -1 (nil)
 (nil))
(call_insn 24 16 25 (set (reg:SI 0 ax)
 (call (mem:QI (symbol_ref:SI ("_Jv_MonitorExit") [flags 0x41] <function_decl 0x40388510 _Jv_MonitorExit>) [0 S1 A8])
 (const_int 4 [0x4]))) -1 (nil)
 (nil)
 (nil))
(insn 25 24 26 (set (reg:SI 65)
 (reg:SI 0 ax)) -1 (nil)
 (nil))
(insn 26 25 27 (set (reg:SI 62)
 (reg:SI 61)) -1 (nil)
 (nil))
(insn 27 26 28 (set (reg:SI 64)
 (reg:SI 63)) -1 (nil)
 (nil))
(jump_insn 28 27 29 (resx 1) -1 (nil)
 (nil))
(barrier 29 28 30)
(code_label 30 29 31 4 "" [0 uses])
 > 
 > public class testcase {
 > 
 > private static class encapsulatedInt {
 > int value;
 > 
 > public encapsulatedInt( int i ) {
 > value = i;
 > }
 > 
 > public synchronized void increment() {
 > value++;
 > }
 > 
 > public int intValue() {
 > return value;
 > }
 > }
 > 
 > public static void main( String args[] ) {
 > encapsulatedInt tester = new encapsulatedInt(0);
 > System.out.println( "value: " + tester.intValue() );
 > tester.increment();
 > System.out.println( "value: " + tester.intValue() );
 > }
 > }
 > 
 > Compiled with GCJ 3.4.0 (with <3.4 everything seems to work
 > as expected):
 > 
 > 	$ gcj -O -o testcase --main=testcase testcase.java
 > $ ./testcase
 > 	value: 0
 > 	value: 0
 > 	$ gcj -o testcase --main=testcase testcase.java
 > 	$ ./testcase
 > 	value: 0
 > 	value: 1
 > 	$ gcj --version
 > 	gcj (GCC) 3.4.0
 > 	[...]
 > 
 > Now, isn't that cool?
 > 
 > Best regards,
 > Tom
 > --------------------------------------------------------------------
 > Thomas Aeby, Kirchweg 52, 1735 Giffers, Switzerland, aeby@graeff.com
 > Voice:(+41)26 4180040 PGP public key available
 > --------------------------------------------------------------------
 > 


More information about the Java mailing list

AltStyle によって変換されたページ (->オリジナル) /