https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93970
Bug ID: 93970 Summary: load via restricted pointer not eliminated after a store via a restricted pointer of incompatible type Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: msebor at gcc dot gnu.org Target Milestone: --- In the test case below the test in f() is folded to false as expected, but the similar test in g() is not folded, even though in both functions the pointers are restricted and in g() they additionally point to incompatible types. $ cat t.c && gcc -O2 -S -Wall -Wextra -fdump-tree-optimized=/dev/stdout t.c void f (int *__restrict p, int *__restrict q) { int t = *q; *p = 0; if (t != *q) // folded to false __builtin_abort (); } void g (int *__restrict p, double *__restrict q) { double t = *q; *p = 0; if (t != *q) // not folded __builtin_abort (); } ;; Function f (f, funcdef_no=0, decl_uid=1931, cgraph_uid=1, symbol_order=0) f (int * restrict p, int * restrict q) { <bb 2> [local count: 1073741824]: *p_3(D) = 0; return; } ;; Function g (g, funcdef_no=1, decl_uid=1936, cgraph_uid=2, symbol_order=1) g (int * restrict p, double * restrict q) { double t; <bb 2> [local count: 1073741824]: t_3 = *q_2(D); *p_4(D) = 0; if (t_3 != t_3) goto <bb 3>; [0.00%] else goto <bb 4>; [100.00%] <bb 3> [count: 0]: __builtin_abort (); <bb 4> [local count: 1073741824]: return; }