[Soot-list] Jimple Code for comparing floats

Chandan Rupakheti rupakhcr at clarkson.edu
Mon Jul 27 17:16:42 EDT 2009


Hello,

I am little surprised on why soot chose to generate jimple using CmplExpr
for EqExpr when comparing floats. I have following code:

public class Test {
    public float field;

    public boolean equals(Object o) {
        if(!(o instanceof Test))
            return false;
        Test that = (Test)o;
        return this.field == that.field;
    }
}

The jimple code for equals method is as follows:

r0 := @this: test.Test
r1 := @parameter0: java.lang.Object
$z0 = r1 instanceof test.Test
if $z0 != 0 goto r2 = (test.Test) r1
return 0
r2 = (test.Test) r1
$f0 = r0.<test.Test: float field>
$f1 = r2.<test.Test: float field>
$b0 = $f0 cmpl $f1                          // Why cmpl instead of == or !=
if $b0 != 0 goto return 0
return 1
return 0

I am wondering why use cmpl operator instead of equality operator for float
types. Nevertheless, equality operator is used for int types. Isn't this
changing the semantics of java code at jimple level (The code is comparing
for less rather than equal for floats)? Am I incorrectly understanding the
functionality of cmpl operator?

Thanks in advance.

-Chandan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.cs.mcgill.ca/pipermail/soot-list/attachments/20090727/fabfbce5/attachment.html 


More information about the Soot-list mailing list