2010-12-17  Bernd Schmidt  <bernds@codesourcery.com>

	Issue #10208

	gcc/
	* config/arm/arm.c (arm_select_cc_mode): Before calling
	arm_select_dominance_cc_mode for AND or IOR operations, ensure
	that op is NE or EQ.

	gcc/testsuite/
	* gcc.c-torture/compile/20101217-1.c: New test.

=== modified file 'gcc/config/arm/arm.c'
--- old/gcc/config/arm/arm.c	2010-12-21 14:13:38 +0000
+++ new/gcc/config/arm/arm.c	2011-01-05 11:32:50 +0000
@@ -10609,12 +10609,14 @@
 
   /* Alternate canonicalizations of the above.  These are somewhat cleaner.  */
   if (GET_CODE (x) == AND
+      && (op == EQ || op == NE)
       && COMPARISON_P (XEXP (x, 0))
       && COMPARISON_P (XEXP (x, 1)))
     return arm_select_dominance_cc_mode (XEXP (x, 0), XEXP (x, 1),
 					 DOM_CC_X_AND_Y);
 
   if (GET_CODE (x) == IOR
+      && (op == EQ || op == NE)
       && COMPARISON_P (XEXP (x, 0))
       && COMPARISON_P (XEXP (x, 1)))
     return arm_select_dominance_cc_mode (XEXP (x, 0), XEXP (x, 1),

=== added file 'gcc/testsuite/gcc.c-torture/compile/20101217-1.c'
--- old/gcc/testsuite/gcc.c-torture/compile/20101217-1.c	1970-01-01 00:00:00 +0000
+++ new/gcc/testsuite/gcc.c-torture/compile/20101217-1.c	2011-01-05 11:32:50 +0000
@@ -0,0 +1,36 @@
+/* Testcase provided by HUAWEI.  */
+#include <stdio.h>
+int main()
+{
+        int cur_k;
+        int cur_j=0;
+        int cur_i=28;
+        unsigned char temp_data[8];
+        unsigned int Data_Size=20;
+
+        for (cur_k=0;cur_j<7;cur_j++,cur_i++) {
+                if (cur_j%2==0) {
+                        temp_data[cur_k++]=0;
+                }
+                if (cur_k==7) {
+                        for (;cur_k>0;cur_k--) {
+                                if (cur_k>2) {
+                                        if ((temp_data[7-cur_k]=='n' || temp_data[7-cur_k]=='N' ) && (temp_data[7-cur_k+1]=='a' || temp_data[7-cur_k+1]=='A' )) {
+                                                break;
+                                        }
+                                }
+                                if (cur_k==1) {
+                                        if (temp_data[7-cur_k]=='n' || temp_data[7-cur_k]=='N' ) {
+                                                break;
+                                        }
+                                }
+                        }
+                        if (cur_k==7) {
+                        } else {
+                                if (cur_k>0)
+                                        printf("dfjk");
+                        }
+                }
+        }
+return 0;
+}

