@@ -321,6 +321,66 @@ ptr_deref_may_alias_ref_p_1 (tree ptr, ao_ref *ref)
321
321
return true;
322
322
}
323
323
324
+ /* Returns true if PTR1 and PTR2 compare unequal because of points-to. */
325
+
326
+ bool
327
+ ptrs_compare_unequal (tree ptr1 , tree ptr2 )
328
+ {
329
+ /* First resolve the pointers down to a SSA name pointer base or
330
+ a VAR_DECL, PARM_DECL or RESULT_DECL. This explicitely does
331
+ not yet try to handle LABEL_DECLs, FUNCTION_DECLs, CONST_DECLs
332
+ or STRING_CSTs which needs points-to adjustments to track them
333
+ in the points-to sets. */
334
+ tree obj1 = NULL_TREE ;
335
+ tree obj2 = NULL_TREE ;
336
+ if (TREE_CODE (ptr1 ) == ADDR_EXPR )
337
+ {
338
+ tree tem = get_base_address (TREE_OPERAND (ptr1 , 0 ));
339
+ if (! tem )
340
+ return false;
341
+ if (TREE_CODE (tem ) == VAR_DECL
342
+ || TREE_CODE (tem ) == PARM_DECL
343
+ || TREE_CODE (tem ) == RESULT_DECL )
344
+ obj1 = tem ;
345
+ else if (TREE_CODE (tem ) == MEM_REF )
346
+ ptr1 = TREE_OPERAND (tem , 0 );
347
+ }
348
+ if (TREE_CODE (ptr2 ) == ADDR_EXPR )
349
+ {
350
+ tree tem = get_base_address (TREE_OPERAND (ptr2 , 0 ));
351
+ if (! tem )
352
+ return false;
353
+ if (TREE_CODE (tem ) == VAR_DECL
354
+ || TREE_CODE (tem ) == PARM_DECL
355
+ || TREE_CODE (tem ) == RESULT_DECL )
356
+ obj2 = tem ;
357
+ else if (TREE_CODE (tem ) == MEM_REF )
358
+ ptr2 = TREE_OPERAND (tem , 0 );
359
+ }
360
+
361
+ if (obj1 && obj2 )
362
+ /* Other code handles this correctly, no need to duplicate it here. */ ;
363
+ else if (obj1 && TREE_CODE (ptr2 ) == SSA_NAME )
364
+ {
365
+ struct ptr_info_def * pi = SSA_NAME_PTR_INFO (ptr2 );
366
+ if (!pi )
367
+ return false;
368
+ return !pt_solution_includes (& pi -> pt , obj1 );
369
+ }
370
+ else if (TREE_CODE (ptr1 ) == SSA_NAME && obj2 )
371
+ {
372
+ struct ptr_info_def * pi = SSA_NAME_PTR_INFO (ptr1 );
373
+ if (!pi )
374
+ return false;
375
+ return !pt_solution_includes (& pi -> pt , obj2 );
376
+ }
377
+
378
+ /* ??? We'd like to handle ptr1 != NULL and ptr1 != ptr2
379
+ but those require pt.null to be conservatively correct. */
380
+
381
+ return false;
382
+ }
383
+
324
384
/* Returns whether reference REF to BASE may refer to global memory. */
325
385
326
386
static bool
0 commit comments