xtensa: Simplify EXTUI instruction maskimm validations

No functional changes.

gcc/ChangeLog:

	* config/xtensa/predicates.md (extui_fldsz_operand): Simplify.
	* config/xtensa/xtensa.cc (xtensa_mask_immediate, print_operand):
	Ditto.
This commit is contained in:
Takayuki 'January June' Suwa 2022-05-13 22:26:30 +09:00 committed by Max Filippov
parent 47b20d027a
commit b753405a5f
2 changed files with 4 additions and 22 deletions

View File

@ -55,7 +55,7 @@
(define_predicate "extui_fldsz_operand"
(and (match_code "const_int")
(match_test "xtensa_mask_immediate ((1 << INTVAL (op)) - 1)")))
(match_test "IN_RANGE (INTVAL (op), 1, 16)")))
(define_predicate "sext_operand"
(if_then_else (match_test "TARGET_SEXT")

View File

@ -456,19 +456,7 @@ xtensa_b4constu (HOST_WIDE_INT v)
bool
xtensa_mask_immediate (HOST_WIDE_INT v)
{
#define MAX_MASK_SIZE 16
int mask_size;
for (mask_size = 1; mask_size <= MAX_MASK_SIZE; mask_size++)
{
if ((v & 1) == 0)
return false;
v = v >> 1;
if (v == 0)
return true;
}
return false;
return IN_RANGE (exact_log2 (v + 1), 1, 16);
}
@ -2430,17 +2418,11 @@ print_operand (FILE *file, rtx x, int letter)
case 'K':
if (GET_CODE (x) == CONST_INT)
{
int num_bits = 0;
unsigned val = INTVAL (x);
while (val & 1)
{
num_bits += 1;
val = val >> 1;
}
if ((val != 0) || (num_bits == 0) || (num_bits > 16))
if (!xtensa_mask_immediate (val))
fatal_insn ("invalid mask", x);
fprintf (file, "%d", num_bits);
fprintf (file, "%d", floor_log2 (val + 1));
}
else
output_operand_lossage ("invalid %%K value");