]> git.ipfire.org Git - thirdparty/gcc.git/commit
s390: Fix operand modifier c
authorStefan Schulze Frielinghaus <stefansf@gcc.gnu.org>
Fri, 9 Jan 2026 14:23:29 +0000 (15:23 +0100)
committerStefan Schulze Frielinghaus <stefansf@gcc.gnu.org>
Fri, 9 Jan 2026 14:23:29 +0000 (15:23 +0100)
commita40666202d19f2b7dd1290e1c2b0d5e2a010335e
treeddbe200c2034b7669af0bb6959a0f367516a9f0b
parentedda700714843ebc7061743bbf383d05e11ecb4a
s390: Fix operand modifier c

Currently, operand modifier c truncates and extends any integer constant
to a signed 8-bit constant whereas the common code implementation just
prints the constant unmodified.  The modifier was introduced in
r0-87728-g963fc8d00baeca matching the new constraint C which ensures
that a constant is an 8-bit signed integer.

In the machine description, operand modifier c is only used for operands
with constraint C.  Therefore, there is no immediate need for some
special constant printing.

Since print_operand() is also used by output_asm_insn(), inline asm is
also affected by this.  Note, in output_asm_insn() we cannot utilize
output_addr_const() since not every CONST_INT is a valid address, i.e.,
we have up to 32-bit immediates and at most 20-bit (long) displacements.

In fact, %cN should behave the same as %N for any CONST_INT operand N,
although, this literally means that the output modifier accepts and
prints immediates which might be larger than any instruction accepts.
Though, regarding accepting or rejecting immediates, this is what
constraints et al. are for.  Therefore, align %cN and %N.

gcc/ChangeLog:

* config/s390/s390.cc (print_operand): Align %cN with %N.
* config/s390/s390.md: Remove comment.

gcc/testsuite/ChangeLog:

* gcc.target/s390/asm-constant-1.c: New test.
gcc/config/s390/s390.cc
gcc/config/s390/s390.md
gcc/testsuite/gcc.target/s390/asm-constant-1.c [new file with mode: 0644]