Abe Skolnik wrote:

In tree-if-conv.c:[…]> if it doesn't trap, but has_non_addressable_refs, can't 
we use
ifcvt_can_use_mask_load_store there too?
if an access could trap, but is addressable,> can't we use the scratchpad 
technique
to get round the trapping problem?

That`s how we deal with loads.  We use the scratchpad in case the condition is 
false.  That way it doesn`t matter if the original code was hypothetically 
dereferencing a null pointer in the condition-false section, for example: we 
aren`t unconditionally executing both sides exactly as written.  On the false 
side, we load from the scratchpad and then ignore the result of that load.

Ok, so I'm looking at tree-if-conv.c:

@@ -876,32 +726,40 @@ if_convertible_gimple_assign_stmt_p (gimple stmt,
       return false;
     }

   /* tree-into-ssa.c uses GF_PLF_1, so avoid it, because
      in between if_convertible_loop_p and combine_blocks
      we can perform loop versioning.  */
   gimple_set_plf (stmt, GF_PLF_2, false);

   if (flag_tree_loop_if_convert_stores)
     {
-      if (ifcvt_could_trap_p (stmt, refs))
+      if (ifcvt_could_trap_p (stmt))
        {
          if (ifcvt_can_use_mask_load_store (stmt))
            {
              gimple_set_plf (stmt, GF_PLF_2, true);
              *any_mask_load_store = true;
              return true;
            }
          if (dump_file && (dump_flags & TDF_DETAILS))
-           fprintf (dump_file, "tree could trap...\n");
+           fprintf (dump_file, "tree could trap\n");
          return false;
        }
+
+      if (has_non_addressable_refs (stmt))
+       {
+         if (dump_file && (dump_flags & TDF_DETAILS))
+           fprintf (dump_file, "has non-addressable memory references\n");
+         return false;
+       }
+
       return true;
     }


I feel I'm being stupid here, but...if ifcvt_could_trap_p && !ifcvt_can_use_mask_load_store, we return false here. Specifically, we return false if ifcvt_could_trap_p && !ifcvt_can_use_mask_load_store && !has_non_addressable_refs. Shouldn't we return true in that case, in order to use the scratchpad technique rather than bail out?

Thanks, Alan

Reply via email to