comparison graal/com.oracle.graal.tests/src/com/oracle/graal/compiler/tests/ConditionTest.java @ 5425:0364a2a874b8

changes towards a canonical representation of comparisons: * new createNullCheckGuard helper method on CiLoweringTool * replaced NullCheckNode with IsNullNode * GuardNode and FixedGuardNode can be negated * keep a list of conditions that are true/false in CheckCastEliminationPhase * FixedGuardNode has only one condition * GraphBuilderPhase creates canonical CompareNodes * BooleanNodes can negate their usages * added junit test for canonicalized compares * removed junit test for negated instanceof * added more thorough graph comparison for junit tests * CheckCastEliminationPhase keeps track of conditions that are known to be true/false
author Lukas Stadler <lukas.stadler@jku.at>
date Tue, 22 May 2012 16:19:02 +0200
parents 80127e4a1742
children d89b20486d87
comparison
equal deleted inserted replaced
5424:068cc464e0cf 5425:0364a2a874b8
39 Random rand = new Random(13); 39 Random rand = new Random(13);
40 for (Condition c1 : Condition.values()) { 40 for (Condition c1 : Condition.values()) {
41 for (Condition c2 : Condition.values()) { 41 for (Condition c2 : Condition.values()) {
42 boolean implies = c1.implies(c2); 42 boolean implies = c1.implies(c2);
43 if (implies) { 43 if (implies) {
44 for (int i = 0; i < 10000; i++) { 44 for (int i = 0; i < 1000; i++) {
45 CiConstant a = CiConstant.forInt(rand.nextInt()); 45 CiConstant a = CiConstant.forInt(rand.nextInt());
46 CiConstant b = CiConstant.forInt(i < 100 ? a.asInt() : rand.nextInt()); 46 CiConstant b = CiConstant.forInt(i < 100 ? a.asInt() : rand.nextInt());
47 boolean result1 = c1.foldCondition(a, b, null, false); 47 boolean result1 = c1.foldCondition(a, b, null, false);
48 boolean result2 = c2.foldCondition(a, b, null, false); 48 boolean result2 = c2.foldCondition(a, b, null, false);
49 if (result1 && implies) { 49 if (result1 && implies) {
61 for (Condition c1 : Condition.values()) { 61 for (Condition c1 : Condition.values()) {
62 for (Condition c2 : Condition.values()) { 62 for (Condition c2 : Condition.values()) {
63 Condition join = c1.join(c2); 63 Condition join = c1.join(c2);
64 assertTrue(join == c2.join(c1)); 64 assertTrue(join == c2.join(c1));
65 if (join != null) { 65 if (join != null) {
66 for (int i = 0; i < 10000; i++) { 66 for (int i = 0; i < 1000; i++) {
67 CiConstant a = CiConstant.forInt(rand.nextInt()); 67 CiConstant a = CiConstant.forInt(rand.nextInt());
68 CiConstant b = CiConstant.forInt(i < 100 ? a.asInt() : rand.nextInt()); 68 CiConstant b = CiConstant.forInt(i < 100 ? a.asInt() : rand.nextInt());
69 boolean result1 = c1.foldCondition(a, b, null, false); 69 boolean result1 = c1.foldCondition(a, b, null, false);
70 boolean result2 = c2.foldCondition(a, b, null, false); 70 boolean result2 = c2.foldCondition(a, b, null, false);
71 boolean resultJoin = join.foldCondition(a, b, null, false); 71 boolean resultJoin = join.foldCondition(a, b, null, false);
84 for (Condition c1 : Condition.values()) { 84 for (Condition c1 : Condition.values()) {
85 for (Condition c2 : Condition.values()) { 85 for (Condition c2 : Condition.values()) {
86 Condition meet = c1.meet(c2); 86 Condition meet = c1.meet(c2);
87 assertTrue(meet == c2.meet(c1)); 87 assertTrue(meet == c2.meet(c1));
88 if (meet != null) { 88 if (meet != null) {
89 for (int i = 0; i < 10000; i++) { 89 for (int i = 0; i < 1000; i++) {
90 CiConstant a = CiConstant.forInt(rand.nextInt()); 90 CiConstant a = CiConstant.forInt(rand.nextInt());
91 CiConstant b = CiConstant.forInt(i < 100 ? a.asInt() : rand.nextInt()); 91 CiConstant b = CiConstant.forInt(i < 100 ? a.asInt() : rand.nextInt());
92 boolean result1 = c1.foldCondition(a, b, null, false); 92 boolean result1 = c1.foldCondition(a, b, null, false);
93 boolean result2 = c2.foldCondition(a, b, null, false); 93 boolean result2 = c2.foldCondition(a, b, null, false);
94 boolean resultMeet = meet.foldCondition(a, b, null, false); 94 boolean resultMeet = meet.foldCondition(a, b, null, false);