OSDN Git Service

* stmt.c (emit_case_nodes): Widen high and low instead of new_bound
authordanglin <danglin@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 11 Jul 2001 18:36:38 +0000 (18:36 +0000)
committerdanglin <danglin@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 11 Jul 2001 18:36:38 +0000 (18:36 +0000)
and low to get correct sign extension in low+high test.

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

gcc/ChangeLog
gcc/stmt.c

index 86549cd..227d48c 100644 (file)
@@ -1,3 +1,8 @@
+2001-07-11  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.
+
 2001-07-11  Janis Johnson <janis@us.ibm.com>
 
        * gcov.c (arcdata): Use gcov_type to fix branch percentage
index 425c185..1097e79 100644 (file)
@@ -6370,26 +6370,23 @@ emit_case_nodes (index, node, default_label, index_type)
            }
          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));