Skip to content

Commit efba001

Browse files
vtjnashararslan
authored andcommitted
runtime-intrinsics: fix definition of shifts
The compiled version does zext, whereas this was doing sext. (cherry picked from commit bceb764)
1 parent 7d0840c commit efba001

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/runtime_intrinsics.c

+5-3
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ jl_value_t *jl_iintrinsic_2(jl_value_t *a, jl_value_t *b, const char *name,
549549
void *pa = jl_data_ptr(a), *pb = jl_data_ptr(b);
550550
unsigned sz = jl_datatype_size(ty);
551551
unsigned sz2 = next_power_of_two(sz);
552-
unsigned szb = jl_datatype_size(tyb);
552+
unsigned szb = cvtb ? jl_datatype_size(tyb) : sz;
553553
if (sz2 > sz) {
554554
/* round type up to the appropriate c-type and set/clear the unused bits */
555555
void *pa2 = alloca(sz2);
@@ -558,10 +558,12 @@ jl_value_t *jl_iintrinsic_2(jl_value_t *a, jl_value_t *b, const char *name,
558558
pa = pa2;
559559
}
560560
if (sz2 > szb) {
561-
/* round type up to the appropriate c-type and set/clear/truncate the unused bits */
561+
/* round type up to the appropriate c-type and set/clear/truncate the unused bits
562+
* (zero-extend if cvtb is set, since in that case b is unsigned while the sign of a comes from the op)
563+
*/
562564
void *pb2 = alloca(sz2);
563565
memcpy(pb2, pb, szb);
564-
memset((char*)pb2 + szb, getsign(pb, sz), sz2 - szb);
566+
memset((char*)pb2 + szb, cvtb ? 0 : getsign(pb, szb), sz2 - szb);
565567
pb = pb2;
566568
}
567569
jl_value_t *newv = lambda2(ty, pa, pb, sz, sz2, list);

0 commit comments

Comments
 (0)