@@ -1224,23 +1224,20 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
1224
1224
}
1225
1225
1226
1226
/* Emit code to compare the two top-most stack values using the 'op' operator. */
1227
- private def genCJUMP (success : asm.Label , failure : asm.Label , op : TestOp , tk : BType , targetIfNoJump : asm.Label ): Unit = {
1228
- if (targetIfNoJump == success) genCJUMP(failure, success, op.negate(), tk, targetIfNoJump)
1227
+ private def genCJUMP (success : asm.Label , failure : asm.Label , op : TestOp , tk : BType , targetIfNoJump : asm.Label , negated : Boolean = false ): Unit = {
1228
+ if (targetIfNoJump == success) genCJUMP(failure, success, op.negate(), tk, targetIfNoJump, negated = ! negated )
1229
1229
else {
1230
1230
if (tk.isIntSizedType) { // BOOL, BYTE, CHAR, SHORT, or INT
1231
1231
bc.emitIF_ICMP(op, success)
1232
1232
} else if (tk.isRef) { // REFERENCE(_) | ARRAY(_)
1233
1233
bc.emitIF_ACMP(op, success)
1234
1234
} else {
1235
1235
import Primitives ._
1236
+ def useCmpG = if (negated) op == GT || op == GE else op == LT || op == LE
1236
1237
(tk : @ unchecked) match {
1237
1238
case LONG => emit(asm.Opcodes .LCMP )
1238
- case FLOAT =>
1239
- if (op == LT || op == LE ) emit(asm.Opcodes .FCMPL )
1240
- else emit(asm.Opcodes .FCMPG )
1241
- case DOUBLE =>
1242
- if (op == LT || op == LE ) emit(asm.Opcodes .DCMPL )
1243
- else emit(asm.Opcodes .DCMPG )
1239
+ case FLOAT => emit(if (useCmpG) asm.Opcodes .FCMPG else asm.Opcodes .FCMPL )
1240
+ case DOUBLE => emit(if (useCmpG) asm.Opcodes .DCMPG else asm.Opcodes .DCMPL )
1244
1241
}
1245
1242
bc.emitIF(op, success)
1246
1243
}
@@ -1249,9 +1246,9 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
1249
1246
}
1250
1247
1251
1248
/* Emits code to compare (and consume) stack-top and zero using the 'op' operator */
1252
- private def genCZJUMP (success : asm.Label , failure : asm.Label , op : TestOp , tk : BType , targetIfNoJump : asm.Label ): Unit = {
1249
+ private def genCZJUMP (success : asm.Label , failure : asm.Label , op : TestOp , tk : BType , targetIfNoJump : asm.Label , negated : Boolean = false ): Unit = {
1253
1250
import Primitives ._
1254
- if (targetIfNoJump == success) genCZJUMP(failure, success, op.negate(), tk, targetIfNoJump)
1251
+ if (targetIfNoJump == success) genCZJUMP(failure, success, op.negate(), tk, targetIfNoJump, negated = ! negated )
1255
1252
else {
1256
1253
if (tk.isIntSizedType) { // BOOL, BYTE, CHAR, SHORT, or INT
1257
1254
bc.emitIF(op, success)
@@ -1261,18 +1258,17 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
1261
1258
case NE => bc emitIFNONNULL success
1262
1259
}
1263
1260
} else {
1261
+ def useCmpG = if (negated) op == GT || op == GE else op == LT || op == LE
1264
1262
(tk : @ unchecked) match {
1265
1263
case LONG =>
1266
1264
emit(asm.Opcodes .LCONST_0 )
1267
1265
emit(asm.Opcodes .LCMP )
1268
1266
case FLOAT =>
1269
1267
emit(asm.Opcodes .FCONST_0 )
1270
- if (op == LT || op == LE ) emit(asm.Opcodes .FCMPL )
1271
- else emit(asm.Opcodes .FCMPG )
1268
+ emit(if (useCmpG) asm.Opcodes .FCMPG else asm.Opcodes .FCMPL )
1272
1269
case DOUBLE =>
1273
1270
emit(asm.Opcodes .DCONST_0 )
1274
- if (op == LT || op == LE ) emit(asm.Opcodes .DCMPL )
1275
- else emit(asm.Opcodes .DCMPG )
1271
+ emit(if (useCmpG) asm.Opcodes .DCMPG else asm.Opcodes .DCMPL )
1276
1272
}
1277
1273
bc.emitIF(op, success)
1278
1274
}
@@ -1287,8 +1283,8 @@ trait BCodeBodyBuilder extends BCodeSkelBuilder {
1287
1283
case ScalaPrimitivesOps .NE => Primitives .NE
1288
1284
case ScalaPrimitivesOps .LT => Primitives .LT
1289
1285
case ScalaPrimitivesOps .LE => Primitives .LE
1290
- case ScalaPrimitivesOps .GE => Primitives .GE
1291
1286
case ScalaPrimitivesOps .GT => Primitives .GT
1287
+ case ScalaPrimitivesOps .GE => Primitives .GE
1292
1288
}
1293
1289
1294
1290
/*
0 commit comments