xtensa: Make use of CLAMPS instruction if configured
authorTakayuki 'January June' Suwa <jjsuwa_sys3175@yahoo.co.jp>
Sun, 26 Feb 2023 17:27:42 +0000 (02:27 +0900)
committerMax Filippov <jcmvbkbc@gmail.com>
Mon, 27 Feb 2023 12:03:33 +0000 (04:03 -0800)
commitce83c3e492c2fa5a08c15b5f4619d58f42a5dcd0
tree214b49a0e36c7ab170b4b1298bd1c3c633ad5f79
parent999b7aab21ca96d58a1dc99f52a3c01cd8760c72
xtensa: Make use of CLAMPS instruction if configured

This patch introduces the use of CLAMPS instruction when the instruction
is configured.

    /* example */
    int test(int a) {
      if (a < -512)
        return -512;
      if (a > 511)
        return 511;
      return a;
    }

    ;; prereq: TARGET_CLAMPS
    test:
clamps a2, a2, 9
ret.n

gcc/ChangeLog:

* config/xtensa/xtensa-protos.h (xtensa_match_CLAMPS_imms_p):
New prototype.
* config/xtensa/xtensa.cc (xtensa_match_CLAMPS_imms_p):
New function.
* config/xtensa/xtensa.h (TARGET_CLAMPS): New macro definition.
* config/xtensa/xtensa.md (*xtensa_clamps): New insn pattern.
gcc/config/xtensa/xtensa-protos.h
gcc/config/xtensa/xtensa.cc
gcc/config/xtensa/xtensa.h
gcc/config/xtensa/xtensa.md