https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104475
--- Comment #4 from Andrew Macleod <amacleod at redhat dot com> --- (In reply to Aldy Hernandez from comment #3) > This isn't the threader but VRP/ranger. > > What happens is that the threader isolates the path, making it easier for > VRP to see the equivalence, and then CCP4 folds the constant into the > problematic call. This is from the .ccp4 pass: > > Folding statement: __atomic_or_fetch_4 (pretmp_29, 64, 0); > Folded into: __atomic_or_fetch_4 (184B, 64, 0); > > In VRP2 the ranger is folding: > > Folding statement: pretmp_29 = &MEM[(struct __atomic_base *)_1 + 184B]._M_i; > Folded into: pretmp_29 = 184B; > > The ranger is determining that _1 is 0 because it has determined that since > _2 is 0 on the 2->3 edge, so is _1, as m_mutex is the first field of _1: > > =========== BB 2 ============ > Imports: _1 > Exports: _1 _2 > _2 : _1(I) > <bb 2> [local count: 1073741824]: > _1 = this_10(D)->d; > _2 = &_1->m_mutex; > MEM[(struct __as_base &)&lock] ={v} {CLOBBER}; > if (_2 != 0B) > goto <bb 5>; [90.00%] > else > goto <bb 3>; [10.00%] > > 2->5 (T) _1 : struct QFutureInterfaceBasePrivate * [1B, +INF] > 2->5 (T) _2 : struct QMutex * [1B, +INF] > 2->3 (F) _1 : struct QFutureInterfaceBasePrivate * [0B, 0B] > 2->3 (F) _2 : struct QMutex * [0B, 0B] > > Andrew, how/where is that we relate _1 and _2 here? I can't seem to find it. > > My gut feeling is that special casing anything in the ranger for this is > wrong. Its via op1_range for OP_ADDR: --param=ranger-debug=tracegori shows: 2120 GORI outgoing_edge for _1 on edge 2->3 2121 GORI compute op 1 (_2) at if (_2 != 0B) GORI LHS =bool [0, 0] GORI Computes _2 = struct QMutex * [0B, 0B] intersect Known range : struct QMutex * VARYING GORI TRUE : (2121) produces (_2) struct QMutex * [0B, 0B] 2122 GORI compute op 1 (_1) at _2 = &_1->m_mutex; GORI LHS =struct QMutex * [0B, 0B] GORI Computes _1 = struct QFutureInterfaceBasePrivate * [0B, 0B] intersect Known range : struct QFutureInterfaceBasePrivate * VARYING GORI TRUE : (2122) produces (_1) struct QFutureInterfaceBasePrivate * [0B, 0B] GORI TRUE : (2120) outgoing_edge (_1) struct QFutureInterfaceBasePrivate * [0B, 0B] so with _2 == 0, the 2122 trace element is solving for _1 in _2 = &_1->m_mutex [0,0] = &_1->m_mutex is it possible for _1 to be anything other than 0 in this case? If so we need to adjust range-ops