public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-8436] aarch64: Fix undefinedness while testing the J constraint [PR100204]
@ 2024-01-25 19:58 Andrew Pinski
  0 siblings, 0 replies; only message in thread
From: Andrew Pinski @ 2024-01-25 19:58 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:f03b8f595b6350732bb0a9a69557c5ed2af085b2

commit r14-8436-gf03b8f595b6350732bb0a9a69557c5ed2af085b2
Author: Andrew Pinski <quic_apinski@quicinc.com>
Date:   Thu Jan 25 08:30:36 2024 -0800

    aarch64: Fix undefinedness while testing the J constraint [PR100204]
    
    The J constraint can invoke undefined behavior due to it taking the
    negative of the ival if ival was HWI_MIN. The fix is simple as casting
    to `unsigned HOST_WIDE_INT` before doing the negative of it. This
    does that.
    
    Committed as obvious after build/test for aarch64-linux-gnu.
    
    gcc/ChangeLog:
    
            PR target/100204
            * config/aarch64/constraints.md (J): Cast to `unsigned HOST_WIDE_INT`
            before taking the negative of it.
    
    Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>

Diff:
---
 gcc/config/aarch64/constraints.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/config/aarch64/constraints.md b/gcc/config/aarch64/constraints.md
index 8566befd7271..a2569cea5102 100644
--- a/gcc/config/aarch64/constraints.md
+++ b/gcc/config/aarch64/constraints.md
@@ -118,7 +118,7 @@
 (define_constraint "J"
  "A constant that can be used with a SUB operation (once negated)."
  (and (match_code "const_int")
-      (match_test "aarch64_uimm12_shift (-ival)")))
+      (match_test "aarch64_uimm12_shift (- (unsigned HOST_WIDE_INT) ival)")))
 
 ;; We can't use the mode of a CONST_INT to determine the context in
 ;; which it is being used, so we must have a separate constraint for

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-01-25 19:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-25 19:58 [gcc r14-8436] aarch64: Fix undefinedness while testing the J constraint [PR100204] Andrew Pinski

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).