🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #2242

Failure to optimize jumps

#2242
From: Joe Weening
Date: Sat, 04 Feb 1989 22:38
36 lines
885 bytes
With GCC 1.33 on a Sun-3 using -O, the program

  foo (i)
       int i;
  {
    if (i > 10) return i;
    return 10;
  }

compiles into:

  _foo:
	  link a6,#0
	  movel a6@(8),d0
	  moveq #10,d1
	  cmpl d0,d1
	  jge L2
	  jra L1
  L2:
	  moveq #10,d0
  L1:
	  unlk a6
	  rts

Version 1.31 of GCC was able to optimize the jumps to:

  _foo:
	  link a6,#0
	  movel a6@(8),d0
	  moveq #10,d1
	  cmpl d0,d1
	  jlt L1
	  moveq #10,d0
  L1:
	  unlk a6
	  rts
Technical Details
Message-ID: <8902042238.AA04881@Gang-of-Four.Stanford.EDU>
Path: arc1-ca.pugleaf.net!utzoo!telly!attcan!uunet!tut.cis.ohio-state.edu!GANG-OF-FOUR.STANFORD.EDU!weening

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!telly!attcan!uunet!tut.cis.ohio-state.edu!GANG-OF-FOUR.STANFORD.EDU!weening
From: weening@GANG-OF-FOUR.STANFORD.EDU (Joe Weening)
Newsgroups: gnu.gcc.bug
Subject: Failure to optimize jumps
Message-ID: <8902042238.AA04881@Gang-of-Four.Stanford.EDU>
Date: 4 Feb 89 22:38:44 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 36