https://gcc.gnu.org/g:fc18779216e4251ba56a9c31ea60e83277e66172
commit r17-5609-gfc18779216e4251ba56a9c31ea60e83277e66172 Author: Stefan Schulze Frielinghaus <[email protected]> Date: Tue Oct 27 06:53:05 2026 +0100 s390: Add another lxa/llxa insn pattern gcc/ChangeLog: * config/s390/s390.md (*lxab_displacement_index): New pattern. (*llxab_displacement_index): Ditto. gcc/testsuite/ChangeLog: * gcc.target/s390/clz-ctz-1.c: Adapt expected output for clzsi_z17. * gcc.target/s390/llxa-4.c: New test. * gcc.target/s390/lxa-5.c: New test. Diff: --- gcc/config/s390/s390.md | 18 ++++++++++++++++++ gcc/testsuite/gcc.target/s390/clz-ctz-1.c | 3 +-- gcc/testsuite/gcc.target/s390/llxa-4.c | 18 ++++++++++++++++++ gcc/testsuite/gcc.target/s390/lxa-5.c | 18 ++++++++++++++++++ 4 files changed, 55 insertions(+), 2 deletions(-) diff --git a/gcc/config/s390/s390.md b/gcc/config/s390/s390.md index 6d59795ea2e0..440df547321a 100644 --- a/gcc/config/s390/s390.md +++ b/gcc/config/s390/s390.md @@ -2059,6 +2059,15 @@ "lxa<lxamode>\t%0,0(%1,0)" [(set_attr "op_type" "RXY")]) +; see testsuite/gcc.target/s390/lxa-5.c +(define_insn "*lxab_displacement_index" + [(set (match_operand:DI 0 "register_operand" "=d") + (sign_extend:DI (plus:SI (match_operand:SI 1 "register_operand" "a") + (match_operand:SI 2 "const_int_operand"))))] + "TARGET_Z17 && INTVAL (operands[2]) >= -0x80000 && INTVAL (operands[2]) <= 0x7FFFF" + "lxab\t%0,%2(%1,0)" + [(set_attr "op_type" "RXY")]) + ; see testsuite/gcc.target/s390/lxa-2.c (define_insn "*lxa<lxamode>_displacement_index" [(set (match_operand:DI 0 "register_operand" "=d") @@ -2104,6 +2113,15 @@ (define_int_attr LLXAMASK [(1 "8589934590") (2 "17179869180") (3 "34359738360") (4 "68719476720")]) +; see testsuite/gcc.target/s390/llxa-4.c +(define_insn "*llxab_displacement_index" + [(set (match_operand:DI 0 "register_operand" "=d") + (zero_extend:DI (plus:SI (match_operand:SI 1 "register_operand" "a") + (match_operand:SI 2 "const_int_operand"))))] + "TARGET_Z17 && INTVAL (operands[2]) >= -0x80000 && INTVAL (operands[2]) <= 0x7FFFF" + "llxab\t%0,%2(%1,0)" + [(set_attr "op_type" "RXY")]) + ; see testsuite/gcc.target/s390/llxa-1.c (define_insn "*llxa<lxamode>_displacement_index" [(set (match_operand:DI 0 "register_operand" "=d") diff --git a/gcc/testsuite/gcc.target/s390/clz-ctz-1.c b/gcc/testsuite/gcc.target/s390/clz-ctz-1.c index 4e81b205d68c..cd7bbc289c43 100644 --- a/gcc/testsuite/gcc.target/s390/clz-ctz-1.c +++ b/gcc/testsuite/gcc.target/s390/clz-ctz-1.c @@ -65,8 +65,7 @@ int clzdi_z9_109 (unsigned long x) /* ** clzsi_z17: ** clzg %r2,%r2 -** ahi %r2,-32 -** lgfr %r2,%r2 +** lxab %r2,-32\(%r2,0\) ** br %r14 */ diff --git a/gcc/testsuite/gcc.target/s390/llxa-4.c b/gcc/testsuite/gcc.target/s390/llxa-4.c new file mode 100644 index 000000000000..440fb790e2c5 --- /dev/null +++ b/gcc/testsuite/gcc.target/s390/llxa-4.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -march=arch15 -dp" } */ +/* { dg-final { scan-assembler-times {\*llxab_displacement_index} 2 } } */ +/* { dg-final { scan-assembler-not {\tllgfr\t} } } */ + +unsigned long +llxab_1 (unsigned long j) +{ + unsigned int i = (unsigned int)j + 42; + return i; +} + +unsigned char +llxab_2 (unsigned char *a, unsigned long j) +{ + unsigned int i = (unsigned int)j + 42; + return a[i]; +} diff --git a/gcc/testsuite/gcc.target/s390/lxa-5.c b/gcc/testsuite/gcc.target/s390/lxa-5.c new file mode 100644 index 000000000000..f13f51960695 --- /dev/null +++ b/gcc/testsuite/gcc.target/s390/lxa-5.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O1 -march=arch15 -dp" } */ +/* { dg-final { scan-assembler-times {\*lxab_displacement_index} 2 } } */ +/* { dg-final { scan-assembler-not {\tlgfr\t} } } */ + +long +lxab_1 (long j) +{ + int i = (int)j + 42; + return i; +} + +char +lxab_2 (char *a, long j) +{ + int i = (int)j + 42; + return a[i]; +}
