nvptx will be the first port to use BImode and have STORE_FLAG_VALUE==-1. That has exposed a bug in combine where we can end up calling num_sign_bit_copies for a BImode value. However, the return value is always 1 in that case, so it doesn't tell us anything and is going to be misinterpreted by the caller.

Bootstrapped and tested on x86_64-linux, together with the other patches. Ok?


Bernd
    	* combine.c (combine_simplify_rtx): Avoid using num_sign_bit_copies
    	for single-bit modes.

diff --git a/gcc/combine.c b/gcc/combine.c
index fe95b41..49c6baa 100644
--- a/gcc/combine.c
+++ b/gcc/combine.c
@@ -5801,10 +5801,14 @@ combine_simplify_rtx (rtx x, enum machine_mode op0_mode, int in_dest,
 	    ;
 
 	  else if (STORE_FLAG_VALUE == -1
-	      && new_code == NE && GET_MODE_CLASS (mode) == MODE_INT
-	      && op1 == const0_rtx
-	      && (num_sign_bit_copies (op0, mode)
-		  == GET_MODE_PRECISION (mode)))
+		   && new_code == NE && GET_MODE_CLASS (mode) == MODE_INT
+		   && op1 == const0_rtx
+		   /* There's always at least one sign bit copy in a
+		      one-bit mode, so the call to num_sign_bit_copies
+		      tells us nothing in that case.  */
+		   && GET_MODE_PRECISION (mode) > 1
+		   && (num_sign_bit_copies (op0, mode)
+		       == GET_MODE_PRECISION (mode)))
 	    return gen_lowpart (mode,
 				expand_compound_operation (op0));
 
@@ -5824,6 +5828,7 @@ combine_simplify_rtx (rtx x, enum machine_mode op0_mode, int in_dest,
 		   && new_code == EQ && GET_MODE_CLASS (mode) == MODE_INT
 		   && op1 == const0_rtx
 		   && mode == GET_MODE (op0)
+		   && GET_MODE_PRECISION (mode) > 1
 		   && (num_sign_bit_copies (op0, mode)
 		       == GET_MODE_PRECISION (mode)))
 	    {

Reply via email to