]> gcc.gnu.org Git - gcc.git/commit
Match: Only allow single use of MIN_EXPR for SAT_TRUNC form 2 [PR115863]
authorPan Li <pan2.li@intel.com>
Thu, 18 Jul 2024 12:16:34 +0000 (20:16 +0800)
committerPan Li <pan2.li@intel.com>
Fri, 19 Jul 2024 00:39:21 +0000 (08:39 +0800)
commit02cc8494745c4235890ad58e93b5acce5a89a775
tree3a11a58357e95d730c0030095871474dc5695b10
parente20ea6bcf8456b655656e50174f58a364fdb7a4e
Match: Only allow single use of MIN_EXPR for SAT_TRUNC form 2 [PR115863]

The SAT_TRUNC form 2 has below pattern matching.
From:
  _18 = MIN_EXPR <left_8, 4294967295>;
  iftmp.0_11 = (unsigned int) _18;

To:
  _18 = MIN_EXPR <left_8, 4294967295>;
  iftmp.0_11 = .SAT_TRUNC (left_8);

But if there is another use of _18 like below,  the transform to the
.SAT_TRUNC may have no earnings.  For example:

From:
  _18 = MIN_EXPR <left_8, 4294967295>; // op_0 def
  iftmp.0_11 = (unsigned int) _18;     // op_0
  stream.avail_out = iftmp.0_11;
  left_37 = left_8 - _18;              // op_0 use

To:
  _18 = MIN_EXPR <left_8, 4294967295>; // op_0 def
  iftmp.0_11 = .SAT_TRUNC (left_8);
  stream.avail_out = iftmp.0_11;
  left_37 = left_8 - _18;              // op_0 use

Pattern recog to .SAT_TRUNC cannot eliminate MIN_EXPR as above.  Then the
backend (for example x86/riscv) will have additional 2-3 more insns
after pattern recog besides the MIN_EXPR.  Thus,  keep the normal truncation
as is should be the better choose.

The below testsuites are passed for this patch:
1. The rv64gcv fully regression tests.
2. The x86 bootstrap tests.
3. The x86 fully regression tests.

PR target/115863

gcc/ChangeLog:

* match.pd: Add single_use check for .SAT_TRUNC form 2.

gcc/testsuite/ChangeLog:

* gcc.target/i386/pr115863-1.c: New test.

Signed-off-by: Pan Li <pan2.li@intel.com>
gcc/match.pd
gcc/testsuite/gcc.target/i386/pr115863-1.c [new file with mode: 0644]
This page took 0.066359 seconds and 6 git commands to generate.