mask right with 31/63 first

This commit is contained in:
Wenyong Huang 2022-07-12 05:12:52 +08:00
parent 8bd5d5d2ef
commit e9409066c2

View File

@ -690,13 +690,12 @@ compile_int_rot(AOTCompContext *comp_ctx, LLVMValueRef left, LLVMValueRef right,
LLVMValueRef bits_minus_shift_count, res, tmp_l, tmp_r; LLVMValueRef bits_minus_shift_count, res, tmp_l, tmp_r;
char *name = is_rotl ? "rotl" : "rotr"; char *name = is_rotl ? "rotl" : "rotr";
/* right is 0 */
if (LLVMIsConstant(right) && (uint64)LLVMConstIntGetZExtValue(right) == 0) {
return left;
}
SHIFT_COUNT_MASK; SHIFT_COUNT_MASK;
/* rotl/rotr with 0 */
if (IS_CONST_ZERO(right))
return left;
/* Calculate (bits - shif_count) */ /* Calculate (bits - shif_count) */
LLVM_BUILD_OP(Sub, is_i32 ? I32_32 : I64_64, right, bits_minus_shift_count, LLVM_BUILD_OP(Sub, is_i32 ? I32_32 : I64_64, right, bits_minus_shift_count,
"bits_minus_shift_count", NULL); "bits_minus_shift_count", NULL);