public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] combine: Don't optimize SIGN_EXTEND of MEM on WORD_REGISTER_OPERATIONS targets [PR113010]
@ 2024-01-16 22:19 Greg McGary
  2024-01-17  6:44 ` Richard Biener
  2024-01-17  7:56 ` YunQiang Su
  0 siblings, 2 replies; 10+ messages in thread
From: Greg McGary @ 2024-01-16 22:19 UTC (permalink / raw)
  To: gcc-patches, Greg McGary; +Cc: Greg McGary

The sign bit of a sign-extending load cannot be known until runtime,
so don't attempt to simplify it in the combiner.

2024-01-11  Greg McGary  <gkm@rivosinc.com>

        PR rtl-optimization/113010
        * combine.cc (expand_compound_operation): Don't simplify
	SIGN_EXTEND of a MEM on WORD_REGISTER_OPERATIONS targets

        * gcc.c-torture/execute/pr113010.c: New test.
---
 gcc/combine.cc                                 | 5 +++++
 gcc/testsuite/gcc.c-torture/execute/pr113010.c | 9 +++++++++
 2 files changed, 14 insertions(+)
 create mode 100644 gcc/testsuite/gcc.c-torture/execute/pr113010.c

diff --git a/gcc/combine.cc b/gcc/combine.cc
index 812553c091e..ba587184dfc 100644
--- a/gcc/combine.cc
+++ b/gcc/combine.cc
@@ -7208,6 +7208,11 @@ expand_compound_operation (rtx x)
       if (len == 0)
 	return x;
 
+      /* Sign-extending loads can never be simplified at compile time.  */
+      if (WORD_REGISTER_OPERATIONS && MEM_P (XEXP (x, 0))
+	  && load_extend_op (inner_mode) == SIGN_EXTEND)
+	return x;
+
       break;
 
     case ZERO_EXTRACT:
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr113010.c b/gcc/testsuite/gcc.c-torture/execute/pr113010.c
new file mode 100644
index 00000000000..a95c613c1df
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/pr113010.c
@@ -0,0 +1,9 @@
+int minus_1 = -1;
+
+int
+main ()
+{
+  if ((0, 0xfffffffful) >= minus_1)
+    __builtin_abort ();
+  return 0;
+}
-- 
2.34.1


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

end of thread, other threads:[~2024-02-08  5:36 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-16 22:19 [PATCH] combine: Don't optimize SIGN_EXTEND of MEM on WORD_REGISTER_OPERATIONS targets [PR113010] Greg McGary
2024-01-17  6:44 ` Richard Biener
2024-01-18  3:53   ` Greg McGary
2024-01-18 16:24     ` Jeff Law
2024-02-02  1:24       ` Greg McGary
2024-02-02  5:24         ` Jeff Law
2024-02-02 22:48           ` Greg McGary
2024-02-05  4:58             ` Jeff Law
2024-02-08  5:36               ` Greg McGary
2024-01-17  7:56 ` YunQiang Su

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