fix alpha c++ failures

John David Anglin dave@hiauly1.hia.nrc.ca
Wed Jul 11 10:55:00 GMT 2001


> I'd rather we did the expansion via CONVERT_EXPR.  That lets us fold

How about this?  Bootstrapped and checked under i686-pc-linux-gnu.  Booted
under hppa1.1-hp-hpux10.20.  PA check is in progress.

Dave
-- 
J. David Anglin                                  dave.anglin@nrc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6605)

2001-07-10  John David Anglin  <dave@hiauly1.hia.nrc.ca>

	* stmt.c (emit_case_nodes): Widen high and low instead of new_bound
	and low to get correct sign extension in low+high test.

--- stmt.c.orig	Mon Jul  9 12:20:51 2001
+++ stmt.c	Tue Jul 10 18:10:44 2001
@@ -6317,26 +6317,23 @@
 	    }
 	  else if (!low_bound && !high_bound)
 	    {
-	      /* Instead of doing two branches, emit
-		 (index-low) <= (high-low).  */
-	      tree new_bound = fold (build (MINUS_EXPR, index_type, node->high,
-					    node->low));
-	      rtx new_index;
-	      
+	      /* Widen LOW and HIGH to the same width as INDEX.  */
+	      tree type = type_for_mode (mode, unsignedp);
+	      tree low = build1 (CONVERT_EXPR, type, node->low);
+	      tree high = build1 (CONVERT_EXPR, type, node->high);
+	      rtx new_index, new_bound;
+
+	      /* Instead of doing two branches, emit one unsigned branch for
+		 (index-low) > (high-low).  */
 	      new_index = expand_binop (mode, sub_optab, index,
-				        convert_modes (mode, imode,
-					  expand_expr (node->low, NULL_RTX,
-						       mode, 0),
-					  unsignedp),
+					expand_expr (low, NULL_RTX, mode, 0),
 				        NULL_RTX, unsignedp, OPTAB_WIDEN);
+	      new_bound = expand_expr (fold (build (MINUS_EXPR, type,
+						    high, low)),
+				       NULL_RTX, mode, 0);
 				
-	      emit_cmp_and_jump_insns (new_index,
-				       convert_modes (mode, imode,
-					 expand_expr (new_bound, NULL_RTX,
-						      mode, 0),
-					 unsignedp),
-				       GT, NULL_RTX, mode, 1, 0,
-				       default_label);
+	      emit_cmp_and_jump_insns (new_index, new_bound, GT, NULL_RTX,
+				       mode, 1, 0, default_label);
 	    }
 
 	  emit_jump (label_rtx (node->code_label));



More information about the Gcc-patches mailing list