Bug 117451 - [compiler] Codegen could better optimize field access when value not required
Summary: [compiler] Codegen could better optimize field access when value not required
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.2 M4   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-11-22 04:13 EST by Philipe Mulet CLA
Modified: 2005-12-13 09:58 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Philipe Mulet CLA 2005-11-22 04:13:43 EST
Build 3.2M3

Code generated for:
public class X {
  public float f0;
  
  public static void main(String[] args)
  {
    long l11 = -26;
    X x = new X();
    System.out.println(
        (((l11 < x.f0) || true) != false));
  }
}

requires the 'f0' field to be accessed (and popped) to ensure proper null check on x.f0.

But following code does not need the field access to be generated in bytecode:
public class X {
  public float f0;
  
  public void main(String[] args)
  {
    long l11 = -26;
    System.out.println(
        (((l11 < f0) || true) != false));
  }
}

or
public class X {
  public static float f0;
  
  public static void main(String[] args)
  {
    long l11 = -26;
    System.out.println(
        (((l11 < f0) || true) != false));
  }
}
Comment 1 Philipe Mulet CLA 2005-11-24 10:57:04 EST
Added BooleanTest#test031. Boolean tests test020,021,022,025,026,027 & 028 are also reflecting the fix.
Comment 2 Philipe Mulet CLA 2005-11-24 11:20:25 EST
Other scenario involving qualified name.
public class X {
	static float f0;
	public static void main(String[] args) {
		System.out.println((X.f0 > 0 || true) == false);
	} 
}
Comment 3 Philipe Mulet CLA 2005-11-25 12:52:40 EST
Tuned SingleNameReference, FieldReference and QualifiedNameReference.
Fixed
Comment 4 Frederic Fusier CLA 2005-12-13 09:58:11 EST
Verified for 3.2 M4 using build I20051213-0010