]> git.ipfire.org Git - thirdparty/gcc.git/commit
s390: Fix builtins vec_rli and verll
authorStefan Schulze Frielinghaus <stefansf@linux.ibm.com>
Mon, 11 Sep 2023 16:11:31 +0000 (18:11 +0200)
committerStefan Schulze Frielinghaus <stefansf@linux.ibm.com>
Mon, 11 Sep 2023 16:11:31 +0000 (18:11 +0200)
commit248df13b966f46649e16dc3c8c92b263790ef503
tree3e80d6a1b1251e0fe94490d5d6c6c8f925929697
parent4a2766ed00a47904dc8b85bf0538aa116d8e658b
s390: Fix builtins vec_rli and verll

The second argument of these builtins is an unsigned immediate.  For
vec_rli the API allows immediates up to 64 bits whereas the instruction
verll only allows immediates up to 32 bits.  Since the shift count
equals the immediate modulo vector element size, truncating those
immediates is fine.

Passing a non-immediate argument to vec_rli already results in an error
message without this patch:

t.c: In function ‘foo’:
t.c:7:10: error: invalid argument 2 for builtin ‘__builtin_s390_verllf’
    7 |   return __builtin_s390_vec_rli (v, x);
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Whereas with this patch

t.c: In function 'foo':
t.c:7:10: error: constant value required for builtin '__builtin_s390_verllf' argument 2
    7 |   return __builtin_s390_vec_rli (v, x);
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

the error message, generated by s390_const_operand_ok, clearly speaks
about a constant argument value.

gcc/ChangeLog:

* config/s390/s390-builtins.def (O_U64): New.
(O1_U64): Ditto.
(O2_U64): Ditto.
(O3_U64): Ditto.
(O4_U64): Ditto.
(O_M12): Change bit position.
(O_S2): Ditto.
(O_S3): Ditto.
(O_S4): Ditto.
(O_S5): Ditto.
(O_S8): Ditto.
(O_S12): Ditto.
(O_S16): Ditto.
(O_S32): Ditto.
(O_ELEM): Ditto.
(O_LIT): Ditto.
(OB_DEF_VAR): Add operand constraints.
(B_DEF): Ditto.
* config/s390/s390.cc (s390_const_operand_ok): Honour 64 bit
operands.
gcc/config/s390/s390-builtins.def
gcc/config/s390/s390.cc