public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/110235] New: Wrong use of us_truncate in SSE and AVX RTL representation
@ 2023-06-13  9:02 ktkachov at gcc dot gnu.org
  2023-06-13 14:00 ` [Bug target/110235] " rguenth at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: ktkachov at gcc dot gnu.org @ 2023-06-13  9:02 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110235

            Bug ID: 110235
           Summary: Wrong use of us_truncate in SSE and AVX RTL
                    representation
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ktkachov at gcc dot gnu.org
                CC: uros at gcc dot gnu.org
  Target Milestone: ---
            Target: x86

After g:921b841350c4fc298d09f6c5674663e0f4208610 added constant-folding for
SS_TRUNCATE and US_TRUNCATE some tests in i386.exp started failing:
FAIL: gcc.target/i386/avx-vpackuswb-1.c execution test
FAIL: gcc.target/i386/avx2-vpackssdw-2.c execution test
FAIL: gcc.target/i386/avx2-vpackusdw-2.c execution test
FAIL: gcc.target/i386/avx2-vpackuswb-2.c execution test
FAIL: gcc.target/i386/sse2-packuswb-1.c execution test

From what I can gather from the documentation for intrinsics like
_mm_packus_epi16 the operation they perform is not what we model as us_truncate
in RTL. That is, they don't perform a truncation while treating their input as
an unsigned value. Rather, they treat the input as a signed value and saturate
it to the unsigned min and max of the narrow mode before truncation. In that
regard they seem similar to the SQMOVUN instructions in aarch64.

I think it'd be best to change the representation of those instructions to a
truncating clamp operation, similar to
g:b747f54a2a930da55330c2861cd1e344f67a88d9 in aarch64.

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2023-07-15  6:04 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-13  9:02 [Bug target/110235] New: Wrong use of us_truncate in SSE and AVX RTL representation ktkachov at gcc dot gnu.org
2023-06-13 14:00 ` [Bug target/110235] " rguenth at gcc dot gnu.org
2023-06-14  4:54 ` [Bug target/110235] [14 Regression] " pinskia at gcc dot gnu.org
2023-06-14  6:25 ` crazylht at gmail dot com
2023-06-14  8:43 ` crazylht at gmail dot com
2023-06-15  8:48 ` ktkachov at gcc dot gnu.org
2023-06-15 23:01 ` pinskia at gcc dot gnu.org
2023-06-19  1:34 ` cvs-commit at gcc dot gnu.org
2023-06-19  1:34 ` cvs-commit at gcc dot gnu.org
2023-06-19  1:40 ` crazylht at gmail dot com
2023-07-15  6:04 ` pinskia at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).