public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-9096] tree-optimization: [PR102622]: wrong code due to signed one bit integer and "a?-1:0"
@ 2021-10-11 21:19 Andrew Pinski
  0 siblings, 0 replies; only message in thread
From: Andrew Pinski @ 2021-10-11 21:19 UTC (permalink / raw)
  To: gcc-cvs

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

commit r11-9096-ge3c06b990b2458b87f72a0c63e0de72cf69f7fc4
Author: Andrew Pinski <apinski@marvell.com>
Date:   Sun Oct 10 01:28:59 2021 +0000

    tree-optimization: [PR102622]: wrong code due to signed one bit integer and "a?-1:0"
    
    Since the problem was already fixed on this branch, we just want to add the
    testcase so it does not regress there.
    
            PR tree-optimization/102622
    
    gcc/testsuite/ChangeLog:
    
            * gcc.c-torture/execute/bitfld-10.c: New test.
    
    (cherry picked from commit 882d806c1a8f9d2d2ade1133de88d63e5d4fe40c)

Diff:
---
 gcc/testsuite/gcc.c-torture/execute/bitfld-10.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/gcc/testsuite/gcc.c-torture/execute/bitfld-10.c b/gcc/testsuite/gcc.c-torture/execute/bitfld-10.c
new file mode 100644
index 00000000000..bdbf5733ce7
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/bitfld-10.c
@@ -0,0 +1,24 @@
+/* PR tree-optimization/102622 */
+/* Wrong code introduced due to phi-opt
+   introducing undefined signed interger overflow
+   with one bit signed integer negation. */
+
+struct f{signed t:1;};
+int g(struct f *a, int t) __attribute__((noipa));
+int g(struct f *a, int t)
+{
+    if (t)
+      a->t = -1;
+    else
+      a->t = 0;
+    int t1 = a->t;
+    if (t1) return 1;
+    return t1;
+}
+
+int main(void)
+{
+    struct f a;
+    if (!g(&a, 1))  __builtin_abort();
+    return 0;
+}


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

only message in thread, other threads:[~2021-10-11 21:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-11 21:19 [gcc r11-9096] tree-optimization: [PR102622]: wrong code due to signed one bit integer and "a?-1:0" 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).