2013-05-03 Joern Rennecke <joern.rennecke@embecosm.com>
authoramylaar <amylaar@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 3 May 2013 11:18:37 +0000 (11:18 +0000)
committeramylaar <amylaar@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 3 May 2013 11:18:37 +0000 (11:18 +0000)
        PR tree-optimization/57027
        * tree-ssa-math-opts.c (convert_mult_to_fma): When checking for
        fnms opportunity, check we got the prerequisite kind of tree / gimple
        before using accessor functions.

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

gcc/ChangeLog
gcc/tree-ssa-math-opts.c

index ad545ae..5a3de45 100644 (file)
@@ -1,3 +1,10 @@
+2013-05-03  Joern Rennecke <joern.rennecke@embecosm.com>
+
+       PR tree-optimization/57027
+       * tree-ssa-math-opts.c (convert_mult_to_fma): When checking
+       for fnms opportunity, check we got the prerequisite kind
+       of tree / gimple before using accessor functions.
+
 2013-05-03  Richard Biener  <rguenther@suse.de>
 
        * double-int.h (lshift): New overload without precision
index e7e09f6..a94172d 100644 (file)
@@ -2581,11 +2581,15 @@ convert_mult_to_fma (gimple mul_stmt, tree op1, tree op2)
          && optab_handler (fnma_optab, TYPE_MODE (type)) != CODE_FOR_nothing)
        {
          tree rhs2 = gimple_assign_rhs2 (use_stmt);
-         gimple stmt2 = SSA_NAME_DEF_STMT (rhs2);
 
-         if (has_single_use (rhs2)
-             && gimple_assign_rhs_code (stmt2) == MULT_EXPR)
-           return false;
+         if (TREE_CODE (rhs2) == SSA_NAME)
+           {
+             gimple stmt2 = SSA_NAME_DEF_STMT (rhs2);
+             if (has_single_use (rhs2)
+                 && is_gimple_assign (stmt2)
+                 && gimple_assign_rhs_code (stmt2) == MULT_EXPR)
+             return false;
+           }
        }
 
       /* We can't handle a * b + a * b.  */