OSDN Git Service

2005-09-09 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 9 Sep 2005 09:00:42 +0000 (09:00 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 9 Sep 2005 09:00:42 +0000 (09:00 +0000)
PR c++/23624
* fold-const.c (fold_ternary): Check truth_value_p before
calling invert_truthvalue.

* g++.dg/tree-ssa/pr23624.C: New testcase.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@104083 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/fold-const.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/tree-ssa/pr23624.C [new file with mode: 0644]

index 185cc13..7ec894c 100644 (file)
@@ -1,3 +1,9 @@
+2005-09-09  Richard Guenther  <rguenther@suse.de>
+
+       PR c++/23624
+       * fold-const.c (fold_ternary): Check truth_value_p before
+       calling invert_truthvalue.
+
 2005-09-09  Nick Clifton  <nickc@redhat.com>
 
        * Makefile.in (LIBGCC_DEPS): Add libgcc2.h.
 2005-09-09  Nick Clifton  <nickc@redhat.com>
 
        * Makefile.in (LIBGCC_DEPS): Add libgcc2.h.
index 2f024b4..4b41adf 100644 (file)
@@ -10006,7 +10006,8 @@ fold_ternary (enum tree_code code, tree type, tree op0, tree op1, tree op2)
 
       /* If the second operand is simpler than the third, swap them
         since that produces better jump optimization results.  */
 
       /* If the second operand is simpler than the third, swap them
         since that produces better jump optimization results.  */
-      if (tree_swap_operands_p (op1, op2, false))
+      if (truth_value_p (TREE_CODE (arg0))
+         && tree_swap_operands_p (op1, op2, false))
        {
          /* See if this can be inverted.  If it can't, possibly because
             it was a floating-point inequality comparison, don't do
        {
          /* See if this can be inverted.  If it can't, possibly because
             it was a floating-point inequality comparison, don't do
index 8070a16..db903b1 100644 (file)
@@ -1,3 +1,8 @@
+2005-09-09  Richard Guenther  <rguenther@suse.de>
+
+       PR c++/23624
+       * g++.dg/tree-ssa/pr23624.C: New testcase.
+
 2005-09-09  Richard Sandiford  <richard@codesourcery.com>
 
        PR fortran/19239
 2005-09-09  Richard Sandiford  <richard@codesourcery.com>
 
        PR fortran/19239
diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr23624.C b/gcc/testsuite/g++.dg/tree-ssa/pr23624.C
new file mode 100644 (file)
index 0000000..769d690
--- /dev/null
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+
+template <int>
+void f()
+{
+    int *t, i;
+    t[i ? 0 : i];
+}