Skip to content

Commit

Permalink
tcg: Use extract2 in tcg_gen_deposit_{i32,i64}
Browse files Browse the repository at this point in the history
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
  • Loading branch information
rth7680 committed Apr 24, 2019
1 parent 02616ba commit b0a6056
Showing 1 changed file with 30 additions and 4 deletions.
34 changes: 30 additions & 4 deletions tcg/tcg-op.c
Expand Up @@ -611,9 +611,22 @@ void tcg_gen_deposit_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2,
return;
}

mask = (1u << len) - 1;
t1 = tcg_temp_new_i32();

if (TCG_TARGET_HAS_extract2_i32) {
if (ofs + len == 32) {
tcg_gen_shli_i32(t1, arg1, len);
tcg_gen_extract2_i32(ret, t1, arg2, len);
goto done;
}
if (ofs == 0) {
tcg_gen_extract2_i32(ret, arg1, arg2, len);
tcg_gen_rotli_i32(ret, ret, len);
goto done;
}
}

mask = (1u << len) - 1;
if (ofs + len < 32) {
tcg_gen_andi_i32(t1, arg2, mask);
tcg_gen_shli_i32(t1, t1, ofs);
Expand All @@ -622,7 +635,7 @@ void tcg_gen_deposit_i32(TCGv_i32 ret, TCGv_i32 arg1, TCGv_i32 arg2,
}
tcg_gen_andi_i32(ret, arg1, ~(mask << ofs));
tcg_gen_or_i32(ret, ret, t1);

done:
tcg_temp_free_i32(t1);
}

Expand Down Expand Up @@ -2024,9 +2037,22 @@ void tcg_gen_deposit_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2,
}
}

mask = (1ull << len) - 1;
t1 = tcg_temp_new_i64();

if (TCG_TARGET_HAS_extract2_i64) {
if (ofs + len == 64) {
tcg_gen_shli_i64(t1, arg1, len);
tcg_gen_extract2_i64(ret, t1, arg2, len);
goto done;
}
if (ofs == 0) {
tcg_gen_extract2_i64(ret, arg1, arg2, len);
tcg_gen_rotli_i64(ret, ret, len);
goto done;
}
}

mask = (1ull << len) - 1;
if (ofs + len < 64) {
tcg_gen_andi_i64(t1, arg2, mask);
tcg_gen_shli_i64(t1, t1, ofs);
Expand All @@ -2035,7 +2061,7 @@ void tcg_gen_deposit_i64(TCGv_i64 ret, TCGv_i64 arg1, TCGv_i64 arg2,
}
tcg_gen_andi_i64(ret, arg1, ~(mask << ofs));
tcg_gen_or_i64(ret, ret, t1);

done:
tcg_temp_free_i64(t1);
}

Expand Down

0 comments on commit b0a6056

Please sign in to comment.