Skip to content

Commit

Permalink
Fixed a compare logical case on s390x
Browse files Browse the repository at this point in the history
Suggested by Carlo Marcelo Arenas Belón
  • Loading branch information
Zoltan Herczeg committed Aug 20, 2024
1 parent 4c4802d commit 2c105e2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
11 changes: 3 additions & 8 deletions sljit_src/sljitNativeS390X.c
Original file line number Diff line number Diff line change
Expand Up @@ -2483,14 +2483,9 @@ static sljit_s32 sljit_emit_sub(struct sljit_compiler *compiler, sljit_s32 op,
ins = (op & SLJIT_32) ? 0xc20d00000000 /* cfi */ : 0xc20c00000000 /* cgfi */;
return emit_ri(compiler, ins, src1, src1, src1w, src2w, RIL_A);
}
}
else {
if ((op & SLJIT_32) || is_u32(src2w)) {
ins = (op & SLJIT_32) ? 0xc20f00000000 /* clfi */ : 0xc20e00000000 /* clgfi */;
return emit_ri(compiler, ins, src1, src1, src1w, src2w, RIL_A);
}
if (is_s16(src2w))
return emit_rie_d(compiler, 0xec00000000db /* alghsik */, (sljit_s32)tmp0, src1, src1w, src2w);
} else if ((op & SLJIT_32) || is_u32(src2w)) {
ins = (op & SLJIT_32) ? 0xc20f00000000 /* clfi */ : 0xc20e00000000 /* clgfi */;
return emit_ri(compiler, ins, src1, src1, src1w, src2w, RIL_A);
}
}
else if (src2 & SLJIT_MEM) {
Expand Down
14 changes: 12 additions & 2 deletions test_src/sljitTest.c
Original file line number Diff line number Diff line change
Expand Up @@ -2249,7 +2249,7 @@ static void test24(void)
/* Playing with conditional flags. */
executable_code code;
struct sljit_compiler* compiler = sljit_create_compiler(NULL);
sljit_u8 buf[43];
sljit_u8 buf[45];
sljit_u32 i;
#ifdef SLJIT_PREF_SHIFT_REG
sljit_s32 shift_reg = SLJIT_PREF_SHIFT_REG;
Expand Down Expand Up @@ -2456,6 +2456,14 @@ static void test24(void)
/* buf[41] */
SET_NEXT_BYTE(SLJIT_SIG_LESS);

sljit_emit_op1(compiler, SLJIT_MOV, SLJIT_R1, 0, SLJIT_IMM, 1);
sljit_emit_op2u(compiler, SLJIT_SUB | SLJIT_SET_LESS, SLJIT_R1, 0, SLJIT_IMM, -1);
/* buf[42] */
SET_NEXT_BYTE(SLJIT_LESS);
sljit_emit_op2u(compiler, SLJIT_SUB | SLJIT_SET_GREATER, SLJIT_R1, 0, SLJIT_IMM, -1);
/* buf[43] */
SET_NEXT_BYTE(SLJIT_GREATER);

sljit_emit_return_void(compiler);

code.code = sljit_generate_code(compiler, 0, NULL);
Expand Down Expand Up @@ -2514,7 +2522,9 @@ static void test24(void)

FAILED(buf[40] != 2, "test24 case 42 failed\n");
FAILED(buf[41] != 1, "test24 case 43 failed\n");
FAILED(buf[42] != 0xaa, "test24 case 44 failed\n");
FAILED(buf[42] != 1, "test24 case 44 failed\n");
FAILED(buf[43] != 2, "test24 case 45 failed\n");
FAILED(buf[44] != 0xaa, "test24 case 46 failed\n");

sljit_free_code(code.code, NULL);
successful_tests++;
Expand Down

0 comments on commit 2c105e2

Please sign in to comment.