From be939b3f59fc14fe99b75e4d09cbadd5bdba2fc9 Mon Sep 17 00:00:00 2001 From: rdapp Date: Mon, 5 Nov 2018 14:18:21 +0000 Subject: [PATCH] S/390: Add loc patterns for QImode and HImode This adds QImode and HImode support to load on condition. gcc/ChangeLog: 2018-11-05 Robin Dapp * config/s390/s390.md: QImode and HImode for load on condition. gcc/testsuite/ChangeLog: 2018-11-05 Robin Dapp * gcc.target/s390/ifcvt-one-insn-bool.c: New test. * gcc.target/s390/ifcvt-one-insn-char.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@265808 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 4 +++ gcc/config/s390/s390.md | 38 ++++++++++++++++++++++ gcc/testsuite/ChangeLog | 5 +++ .../gcc.target/s390/ifcvt-one-insn-bool.c | 24 ++++++++++++++ .../gcc.target/s390/ifcvt-one-insn-char.c | 26 +++++++++++++++ 5 files changed, 97 insertions(+) create mode 100644 gcc/testsuite/gcc.target/s390/ifcvt-one-insn-bool.c create mode 100644 gcc/testsuite/gcc.target/s390/ifcvt-one-insn-char.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c76911db0aa..a0f35e63327 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,9 @@ 2018-11-05 Robin Dapp + * config/s390/s390.md: QImode and HImode for load on condition. + +2018-11-05 Robin Dapp + * config/s390/predicates.md: Fix typo. * config/s390/s390.md: Allow immediates for load on condition. diff --git a/gcc/config/s390/s390.md b/gcc/config/s390/s390.md index 644781f8ad6..8e7b285e1c3 100644 --- a/gcc/config/s390/s390.md +++ b/gcc/config/s390/s390.md @@ -6592,6 +6592,44 @@ XEXP (operands[1], 1)); }) +;; +;; - We do not have instructions for QImode or HImode but still +;; enable load on condition/if conversion for them. +(define_expand "movcc" + [(set (match_operand:HQI 0 "nonimmediate_operand" "") + (if_then_else:HQI (match_operand 1 "comparison_operator" "") + (match_operand:HQI 2 "loc_operand" "") + (match_operand:HQI 3 "loc_operand" "")))] + "TARGET_Z196" +{ + /* Emit the comparison insn in case we do not already have a comparison + result. */ + if (!s390_comparison (operands[1], VOIDmode)) + operands[1] = s390_emit_compare (GET_CODE (operands[1]), + XEXP (operands[1], 0), + XEXP (operands[1], 1)); + + rtx then = operands[2]; + rtx els = operands[3]; + + if ((!TARGET_Z13 && CONSTANT_P (then)) || MEM_P (then)) + then = force_reg (mode, then); + if ((!TARGET_Z13 && CONSTANT_P (els)) || MEM_P (els)) + els = force_reg (mode, els); + + if (!CONSTANT_P (then)) + then = simplify_gen_subreg (E_SImode, then, mode, 0); + if (!CONSTANT_P (els)) + els = simplify_gen_subreg (E_SImode, els, mode, 0); + + rtx tmp_target = gen_reg_rtx (E_SImode); + emit_insn (gen_movsicc (tmp_target, operands[1], then, els)); + emit_move_insn (operands[0], gen_lowpart (mode, tmp_target)); + DONE; +}) + + + ; locr, loc, stoc, locgr, locg, stocg, lochi, locghi (define_insn "*movcc" [(set (match_operand:GPR 0 "nonimmediate_operand" "=d,d,d,d,d,d,S,S") diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 47166959123..ae7ed523955 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-10-26 Robin Dapp + + * gcc.target/s390/ifcvt-one-insn-bool.c: New test. + * gcc.target/s390/ifcvt-one-insn-char.c: New test. + 2018-11-05 Robin Dapp * gcc.dg/loop-8.c: On s390, always run the test with -march=zEC12. diff --git a/gcc/testsuite/gcc.target/s390/ifcvt-one-insn-bool.c b/gcc/testsuite/gcc.target/s390/ifcvt-one-insn-bool.c new file mode 100644 index 00000000000..0a96b71f458 --- /dev/null +++ b/gcc/testsuite/gcc.target/s390/ifcvt-one-insn-bool.c @@ -0,0 +1,24 @@ +/* Check load on condition for bool. */ + +/* { dg-do compile { target { s390*-*-* } } } */ +/* { dg-options "-O2 -march=z13" } */ + +/* { dg-final { scan-assembler "lochinh\t%r.?,1" } } */ +#include + +int foo (int *a, unsigned int n) +{ + int min = 999999; + bool bla = false; + for (int i = 0; i < n; i++) + { + if (a[i] < min) + { + bla = true; + } + } + + if (bla) + min += 1; + return min; +} diff --git a/gcc/testsuite/gcc.target/s390/ifcvt-one-insn-char.c b/gcc/testsuite/gcc.target/s390/ifcvt-one-insn-char.c new file mode 100644 index 00000000000..9c3d041618b --- /dev/null +++ b/gcc/testsuite/gcc.target/s390/ifcvt-one-insn-char.c @@ -0,0 +1,26 @@ +/* Check load on condition for global char. */ + +/* { dg-do compile { target { s390*-*-* } } } */ +/* { dg-options "-O2 -march=z13" } */ + +/* { dg-final { scan-assembler "locrnh\t%r.?,%r.?" } } */ +#include + +char g = 42; + +int foo (int *a, unsigned int n) +{ + int min = 999999; + char bla = 3; + for (int i = 0; i < n; i++) + { + if (a[i] < min) + { + bla = g; + } + } + + if (bla == 42) + min += 1; + return min; +} -- 2.11.4.GIT