Skip to content

Commit 758d8fd

Browse files
committed
use shr and sar on x86 in builder versions
1 parent c2a4a88 commit 758d8fd

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/builder.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -765,12 +765,20 @@ static inline void cj_builder_shl(cj_ctx *ctx, cj_operand dst, int shift) {
765765

766766
static inline void cj_builder_shr(cj_ctx *ctx, cj_operand dst, int shift) {
767767
if (!ctx || shift == 0) return;
768+
#if defined(__x86_64__) || defined(_M_X64)
769+
cj_shr(ctx, dst, cj_make_constant((uint64_t)shift));
770+
#elif defined(__aarch64__) || defined(_M_ARM64)
768771
cj_lsr(ctx, dst, cj_make_constant((uint64_t)shift));
772+
#endif
769773
}
770774

771775
static inline void cj_builder_sar(cj_ctx *ctx, cj_operand dst, int shift) {
772776
if (!ctx || shift == 0) return;
777+
#if defined(__x86_64__) || defined(_M_X64)
778+
cj_sar(ctx, dst, cj_make_constant((uint64_t)shift));
779+
#elif defined(__aarch64__) || defined(_M_ARM64)
773780
cj_asr(ctx, dst, cj_make_constant((uint64_t)shift));
781+
#endif
774782
}
775783

776784
static inline void cj_builder_cset(cj_ctx *ctx, cj_operand dst, cj_condition cond) {

0 commit comments

Comments
 (0)