[CPU] Fix incorrect all_same detection in constant vector shift paths

The loop conditions `n < 8 - n` and `n < 4 - n` terminated early,
only checking the first half of elements. This caused EmitInt16 and
EmitInt32 to incorrectly take the uniform shift path when trailing
elements had different shift amounts.

Resolves potential issues in SHL, SHR, and SHA.
This commit is contained in:
Herman S.
2026-02-12 09:31:54 +09:00
parent 10e8224a63
commit bb70e5c651
4 changed files with 139 additions and 6 deletions

View File

@@ -1057,7 +1057,7 @@ struct VECTOR_SHL_V128
if (i.src2.is_constant) {
const auto& shamt = i.src2.constant();
bool all_same = true;
for (size_t n = 0; n < 8 - n; ++n) {
for (size_t n = 0; n < 7; ++n) {
if (shamt.u16[n] != shamt.u16[n + 1]) {
all_same = false;
break;
@@ -1135,7 +1135,7 @@ struct VECTOR_SHL_V128
if (i.src2.is_constant) {
const auto& shamt = i.src2.constant();
bool all_same = true;
for (size_t n = 0; n < 4 - n; ++n) {
for (size_t n = 0; n < 3; ++n) {
if (shamt.u32[n] != shamt.u32[n + 1]) {
all_same = false;
break;
@@ -1335,7 +1335,7 @@ struct VECTOR_SHR_V128
if (i.src2.is_constant) {
const auto& shamt = i.src2.constant();
bool all_same = true;
for (size_t n = 0; n < 8 - n; ++n) {
for (size_t n = 0; n < 7; ++n) {
if (shamt.u16[n] != shamt.u16[n + 1]) {
all_same = false;
break;
@@ -1418,7 +1418,7 @@ struct VECTOR_SHR_V128
if (i.src2.is_constant) {
const auto& shamt = i.src2.constant();
bool all_same = true;
for (size_t n = 0; n < 4 - n; ++n) {
for (size_t n = 0; n < 3; ++n) {
if (shamt.u32[n] != shamt.u32[n + 1]) {
all_same = false;
break;
@@ -1636,7 +1636,7 @@ struct VECTOR_SHA_V128
if (i.src2.is_constant) {
const auto& shamt = i.src2.constant();
bool all_same = true;
for (size_t n = 0; n < 8 - n; ++n) {
for (size_t n = 0; n < 7; ++n) {
if (shamt.u16[n] != shamt.u16[n + 1]) {
all_same = false;
break;
@@ -1711,7 +1711,7 @@ struct VECTOR_SHA_V128
if (i.src2.is_constant) {
const auto& shamt = i.src2.constant();
bool all_same = true;
for (size_t n = 0; n < 4 - n; ++n) {
for (size_t n = 0; n < 3; ++n) {
if (shamt.u32[n] != shamt.u32[n + 1]) {
all_same = false;
break;