aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@libertysurf.fr>2007-05-17 15:29:10 +0200
committerEric Botcazou <ebotcazou@gcc.gnu.org>2007-05-17 13:29:10 +0000
commit4eff80454bb64e2fd93336cb021695f7453cd41a (patch)
tree0aafa5bab3ec3b34d8e06253401a45d19656466b /gcc
parent0881653ce25559ff10a7f8d5832f8d120eb27568 (diff)
downloadgcc-4eff80454bb64e2fd93336cb021695f7453cd41a.zip
gcc-4eff80454bb64e2fd93336cb021695f7453cd41a.tar.gz
gcc-4eff80454bb64e2fd93336cb021695f7453cd41a.tar.bz2
re PR rtl-optimization/31691 (optimized code taking the wrong branch)
PR rtl-optimization/31691 * combine.c (simplify_set): Build a new src pattern instead of substituting its operands in the COMPARE case. From-SVN: r124797
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/combine.c10
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/20070517-1.c41
4 files changed, 56 insertions, 5 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 247a42d..8286104 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2007-05-17 Eric Botcazou <ebotcazou@libertysurf.fr>
+
+ PR rtl-optimization/31691
+ * combine.c (simplify_set): Build a new src pattern instead of
+ substituting its operands in the COMPARE case.
+
2007-05-17 Zdenek Dvorak <dvorakz@suse.cz>
* tree-vrp.c (finalize_jump_threads): Do not care about dominance info.
diff --git a/gcc/combine.c b/gcc/combine.c
index 99da26d..7589aac 100644
--- a/gcc/combine.c
+++ b/gcc/combine.c
@@ -5343,14 +5343,14 @@ simplify_set (rtx x)
}
else if (GET_MODE (op0) == compare_mode && op1 == const0_rtx)
{
- SUBST(SET_SRC (x), op0);
+ SUBST (SET_SRC (x), op0);
src = SET_SRC (x);
}
- else
+ /* Otherwise, update the COMPARE if needed. */
+ else if (XEXP (src, 0) != op0 || XEXP (src, 1) != op1)
{
- /* Otherwise, update the COMPARE if needed. */
- SUBST (XEXP (src, 0), op0);
- SUBST (XEXP (src, 1), op1);
+ SUBST (SET_SRC (x), gen_rtx_COMPARE (compare_mode, op0, op1));
+ src = SET_SRC (x);
}
}
else
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index a78f675..7a219b3 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2007-05-17 Eric Botcazou <ebotcazou@libertysurf.fr>
+
+ * gcc.c-torture/execute/20070517-1.c: New test.
+
2007-05-17 Daniel Franke <franke.daniel@gmail.com>
PR fortran/31919
diff --git a/gcc/testsuite/gcc.c-torture/execute/20070517-1.c b/gcc/testsuite/gcc.c-torture/execute/20070517-1.c
new file mode 100644
index 0000000..c81cbc6
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/20070517-1.c
@@ -0,0 +1,41 @@
+/* PR rtl-optimization/31691 */
+/* Origin: Chi-Hua Chen <stephaniechc-gccbug@yahoo.com> */
+
+extern void abort (void);
+
+static int get_kind(int) __attribute__ ((noinline));
+
+static int get_kind(int v)
+{
+ volatile int k = v;
+ return k;
+}
+
+static int some_call(void) __attribute__ ((noinline));
+
+static int some_call(void)
+{
+ return 0;
+}
+
+static void example (int arg)
+{
+ int tmp, kind = get_kind (arg);
+
+ if (kind == 9 || kind == 10 || kind == 5)
+ {
+ if (some_call() == 0)
+ {
+ if (kind == 9 || kind == 10)
+ tmp = arg;
+ else
+ abort();
+ }
+ }
+}
+
+int main(void)
+{
+ example(10);
+ return 0;
+}