aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorUlrich Weigand <uweigand@de.ibm.com>2004-03-11 22:48:36 +0000
committerUlrich Weigand <uweigand@gcc.gnu.org>2004-03-11 22:48:36 +0000
commitbbe708a3914c49b9124bd2b44a9d62d5640ffd27 (patch)
tree07534e5cce41f7cf4660e3ee80dff3853f126e1d /gcc
parent0e808055da764187cb050bbfe06baf48dd235184 (diff)
downloadgcc-bbe708a3914c49b9124bd2b44a9d62d5640ffd27.zip
gcc-bbe708a3914c49b9124bd2b44a9d62d5640ffd27.tar.gz
gcc-bbe708a3914c49b9124bd2b44a9d62d5640ffd27.tar.bz2
combine.c (if_then_else_cond): Check for NULL return value of simplify_gen_subreg.
ChangeLog: * combine.c (if_then_else_cond): Check for NULL return value of simplify_gen_subreg. testsuite/ChangeLog: * gcc.dg/20040310-1.c: New test. From-SVN: r79347
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/combine.c14
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.dg/20040310-1.c34
4 files changed, 52 insertions, 5 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index bf5617d..8526cfb 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2004-03-11 Ulrich Weigand <uweigand@de.ibm.com>
+
+ * combine.c (if_then_else_cond): Check for NULL return value of
+ simplify_gen_subreg.
+
2004-03-11 Richard Sandiford <rsandifo@redhat.com>
PR target/14496
diff --git a/gcc/combine.c b/gcc/combine.c
index 497e826..c627187 100644
--- a/gcc/combine.c
+++ b/gcc/combine.c
@@ -7378,12 +7378,16 @@ if_then_else_cond (rtx x, rtx *ptrue, rtx *pfalse)
&& 0 != (cond0 = if_then_else_cond (SUBREG_REG (x),
&true0, &false0)))
{
- *ptrue = simplify_gen_subreg (mode, true0,
+ true0 = simplify_gen_subreg (mode, true0,
+ GET_MODE (SUBREG_REG (x)), SUBREG_BYTE (x));
+ false0 = simplify_gen_subreg (mode, false0,
GET_MODE (SUBREG_REG (x)), SUBREG_BYTE (x));
- *pfalse = simplify_gen_subreg (mode, false0,
- GET_MODE (SUBREG_REG (x)), SUBREG_BYTE (x));
-
- return cond0;
+ if (true0 && false0)
+ {
+ *ptrue = true0;
+ *pfalse = false0;
+ return cond0;
+ }
}
/* If X is a constant, this isn't special and will cause confusions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 90916b8..da07a04 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2004-03-11 Ulrich Weigand <uweigand@de.ibm.com>
+
+ * gcc.dg/20040310-1.c: New test.
+
2004-03-11 Roger Sayle <roger@eyesopen.com>
* gcc.c-torture/execute/20040311-1.c: New test case.
diff --git a/gcc/testsuite/gcc.dg/20040310-1.c b/gcc/testsuite/gcc.dg/20040310-1.c
new file mode 100644
index 0000000..104e98d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/20040310-1.c
@@ -0,0 +1,34 @@
+/* This caused cc1 to segfault on s390x-ibm-linux
+ due to a bug in if_then_else_cond (combine.c). */
+
+/* { dg-do compile } */
+/* { dg-options "-O1" } */
+
+extern void use (unsigned int x);
+
+int main (void)
+{
+ union
+ {
+ unsigned int x;
+ unsigned long pad;
+ } A;
+
+ struct
+ {
+ unsigned int x : 1;
+ } B;
+
+ A.x = 1;
+ B.x = 1;
+ A.x /= B.x;
+ use (A.x);
+
+ A.x = 1;
+ B.x = 1;
+ B.x /= A.x;
+ use (B.x);
+
+ return 0;
+}
+