This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix PR40640


This fixes PR40640, we shouldn't be using an integer subtype for
arithmetic.  Certainly not a single-valued one, or VRP will be
confused a lot.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.

Richard.

2009-07-03  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/40640
	* tree-switch-conversion.c (build_arrays): Perform arithmetic
	in original type.

	* gcc.c-torture/compile/pr40640.c: New testcase.

Index: gcc/tree-switch-conversion.c
===================================================================
*** gcc/tree-switch-conversion.c	(revision 149208)
--- gcc/tree-switch-conversion.c	(working copy)
*************** build_arrays (gimple swtch)
*** 556,568 ****
    gsi = gsi_for_stmt (swtch);
  
    arr_index_type = build_index_type (info.range_size);
!   tmp = create_tmp_var (arr_index_type, "csti");
    add_referenced_var (tmp);
    tidx = make_ssa_name (tmp, NULL);
    sub = fold_build2 (MINUS_EXPR, TREE_TYPE (info.index_expr), info.index_expr,
  		     fold_convert (TREE_TYPE (info.index_expr),
  				   info.range_min));
!   sub = force_gimple_operand_gsi (&gsi, fold_convert (arr_index_type, sub),
  				  false, NULL, true, GSI_SAME_STMT);
    stmt = gimple_build_assign (tidx, sub);
    SSA_NAME_DEF_STMT (tidx) = stmt;
--- 556,568 ----
    gsi = gsi_for_stmt (swtch);
  
    arr_index_type = build_index_type (info.range_size);
!   tmp = create_tmp_var (TREE_TYPE (info.index_expr), "csti");
    add_referenced_var (tmp);
    tidx = make_ssa_name (tmp, NULL);
    sub = fold_build2 (MINUS_EXPR, TREE_TYPE (info.index_expr), info.index_expr,
  		     fold_convert (TREE_TYPE (info.index_expr),
  				   info.range_min));
!   sub = force_gimple_operand_gsi (&gsi, sub,
  				  false, NULL, true, GSI_SAME_STMT);
    stmt = gimple_build_assign (tidx, sub);
    SSA_NAME_DEF_STMT (tidx) = stmt;
Index: gcc/testsuite/gcc.c-torture/compile/pr40640.c
===================================================================
*** gcc/testsuite/gcc.c-torture/compile/pr40640.c	(revision 0)
--- gcc/testsuite/gcc.c-torture/compile/pr40640.c	(revision 0)
***************
*** 0 ****
--- 1,15 ----
+ void decode_opic_address(int *);
+ void sim_io_printf_filtered2 (int, unsigned);
+ void
+ hw_opic_io_read_buffer(int index)
+ {
+   unsigned reg = 0;
+   decode_opic_address(&index);
+   switch (index)
+     {
+       case 0:
+ 	  reg = 1;
+     }
+   sim_io_printf_filtered2 (index, reg);
+ }
+ 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]