diff mbox

Fix for PR c/57563

Message ID BF230D13CA30DD48930C31D4099330003A42D8CE@FMSMSX101.amr.corp.intel.com
State New
Headers show

Commit Message

Iyer, Balaji V June 10, 2013, 10:15 p.m. UTC
> -----Original Message-----
> From: Joseph Myers [mailto:joseph@codesourcery.com]
> Sent: Monday, June 10, 2013 5:18 PM
> To: Iyer, Balaji V
> Cc: gcc-patches@gcc.gnu.org; Jakub Jelinek; mpolacek@gcc.gnu.org
> Subject: RE: [PATCH] Fix for PR c/57563
> 
> On Mon, 10 Jun 2013, Iyer, Balaji V wrote:
> 
> > I looked into it a bit more detail. It was an error on my side. I was
> > removing the excess precision expr layer instead of fully folding it.
> > I did that change (i.e. fully fold the expression) and all the errors
> > seem to go away. Here is the fixed patch that fixes PR c/57563. It
> > passes for
> > 32 bit and 64 bit tests.  Here are the changelog entries:
> 
> This version is better, but if removing an EXCESS_PRECISION_EXPR there caused
> problems, why is it OK to remove CONVERT_EXPR and NOP_EXPR like you still
> do - won't that also cause type mismatches (at least if the conversions are to
> types that count as sufficiently different for GIMPLE purposes - say conversions
> between 32-bit and 64-bit integers)?  Maybe you actually need to fold without
> removing any such wrappers first at all?

I looked into it and they were an artifact of previous implementation. Those while loops were not even being entered. Thus, I took them out. Here is a fixed patch. 

Thanks,

Balaji V. Iyer.


> 
> --
> Joseph S. Myers
> joseph@codesourcery.com

Comments

Joseph Myers June 10, 2013, 10:45 p.m. UTC | #1
On Mon, 10 Jun 2013, Iyer, Balaji V wrote:

> > This version is better, but if removing an EXCESS_PRECISION_EXPR there caused
> > problems, why is it OK to remove CONVERT_EXPR and NOP_EXPR like you still
> > do - won't that also cause type mismatches (at least if the conversions are to
> > types that count as sufficiently different for GIMPLE purposes - say conversions
> > between 32-bit and 64-bit integers)?  Maybe you actually need to fold without
> > removing any such wrappers first at all?
> 
> I looked into it and they were an artifact of previous implementation. 
> Those while loops were not even being entered. Thus, I took them out. 
> Here is a fixed patch.

Thanks, this patch is OK.
diff mbox

Patch

diff --git a/gcc/c/c-array-notation.c b/gcc/c/c-array-notation.c
old mode 100644
new mode 100755
index b1040da..3285969
--- a/gcc/c/c-array-notation.c
+++ b/gcc/c/c-array-notation.c
@@ -143,25 +143,18 @@  fix_builtin_array_notation_fn (tree an_builtin_fn, tree *new_var)
       || an_type == BUILT_IN_CILKPLUS_SEC_REDUCE_MUTATING)
     {
       call_fn = CALL_EXPR_ARG (an_builtin_fn, 2);
-      while (TREE_CODE (call_fn) == CONVERT_EXPR
-	     || TREE_CODE (call_fn) == NOP_EXPR)
+      if (TREE_CODE (call_fn) == ADDR_EXPR)
 	call_fn = TREE_OPERAND (call_fn, 0);
-      call_fn = TREE_OPERAND (call_fn, 0);
-      
       identity_value = CALL_EXPR_ARG (an_builtin_fn, 0);
-      while (TREE_CODE (identity_value) == CONVERT_EXPR
-	     || TREE_CODE (identity_value) == NOP_EXPR)
-	identity_value = TREE_OPERAND (identity_value, 0);
       func_parm = CALL_EXPR_ARG (an_builtin_fn, 1);
     }
   else
     func_parm = CALL_EXPR_ARG (an_builtin_fn, 0);
   
-  while (TREE_CODE (func_parm) == CONVERT_EXPR
-	 || TREE_CODE (func_parm) == EXCESS_PRECISION_EXPR
-	 || TREE_CODE (func_parm) == NOP_EXPR)
-    func_parm = TREE_OPERAND (func_parm, 0);
-
+  /* Fully fold any EXCESSIVE_PRECISION EXPR that can occur in the function
+     parameter.  */
+  func_parm = c_fully_fold (func_parm, false, NULL);
+  
   location = EXPR_LOCATION (an_builtin_fn);
   
   if (!find_rank (location, an_builtin_fn, an_builtin_fn, true, &rank))
diff --git a/gcc/testsuite/c-c++-common/cilk-plus/AN/builtin_fn_mutating.c b/gcc/testsuite/c-c++-common/cilk-plus/AN/builtin_fn_mutating.c
index 6635565..7c194c2 100644
--- a/gcc/testsuite/c-c++-common/cilk-plus/AN/builtin_fn_mutating.c
+++ b/gcc/testsuite/c-c++-common/cilk-plus/AN/builtin_fn_mutating.c
@@ -44,11 +44,11 @@  int main(void)
   max_value = array3[0] * array4[0];
   for (ii = 0; ii < 10; ii++)
     if (array3[ii] * array4[ii] > max_value) {
-      max_value = array3[ii] * array4[ii];
       max_index = ii;
     }
     
-  
+  for (ii = 0; ii < 10; ii++)
+    my_func (&max_value, array3[ii] * array4[ii]);
   
 #if HAVE_IO
   for (ii = 0; ii < 10; ii++)