|
@@ -777,17 +777,25 @@ compile_int_rot(AOTCompContext *comp_ctx, LLVMValueRef left, LLVMValueRef right,
|
|
|
if (IS_CONST_ZERO(right))
|
|
if (IS_CONST_ZERO(right))
|
|
|
return left;
|
|
return left;
|
|
|
|
|
|
|
|
- /* Calculate (bits - shif_count) */
|
|
|
|
|
|
|
+ /* Calculate (bits - shift_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);
|
|
|
|
|
+ /* Calculate (bits - shift_count) & mask */
|
|
|
|
|
+ bits_minus_shift_count =
|
|
|
|
|
+ LLVMBuildAnd(comp_ctx->builder, bits_minus_shift_count,
|
|
|
|
|
+ is_i32 ? I32_31 : I64_63, "bits_minus_shift_count_and");
|
|
|
|
|
+ if (!bits_minus_shift_count) {
|
|
|
|
|
+ aot_set_last_error("llvm build and failed.");
|
|
|
|
|
+ return NULL;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
if (is_rotl) {
|
|
if (is_rotl) {
|
|
|
- /* left<<count | left>>(BITS-count) */
|
|
|
|
|
|
|
+ /* (left << count) | (left >> ((BITS - count) & mask)) */
|
|
|
LLVM_BUILD_OP(Shl, left, right, tmp_l, "tmp_l", NULL);
|
|
LLVM_BUILD_OP(Shl, left, right, tmp_l, "tmp_l", NULL);
|
|
|
LLVM_BUILD_OP(LShr, left, bits_minus_shift_count, tmp_r, "tmp_r", NULL);
|
|
LLVM_BUILD_OP(LShr, left, bits_minus_shift_count, tmp_r, "tmp_r", NULL);
|
|
|
}
|
|
}
|
|
|
else {
|
|
else {
|
|
|
- /* left>>count | left<<(BITS-count) */
|
|
|
|
|
|
|
+ /* (left >> count) | (left << ((BITS - count) & mask)) */
|
|
|
LLVM_BUILD_OP(LShr, left, right, tmp_l, "tmp_l", NULL);
|
|
LLVM_BUILD_OP(LShr, left, right, tmp_l, "tmp_l", NULL);
|
|
|
LLVM_BUILD_OP(Shl, left, bits_minus_shift_count, tmp_r, "tmp_r", NULL);
|
|
LLVM_BUILD_OP(Shl, left, bits_minus_shift_count, tmp_r, "tmp_r", NULL);
|
|
|
}
|
|
}
|