>> This patch is meant to add match rules to simplify patterns as: >> >> o. (pointer + offset_a) - (pointer + offset_b) -> (ptrdiff_t) (offset_a >> - offset_b) >> o. (pointer_a + offset) - (pointer_b + offset) -> (pointer_a - pointer_b)
> You are also changing the existing pattern which IIRC tries to > preserve the undefinedness of overflow in offset_a - offset_b. > Without an explanation it's hard to guess why you think eliding > this conversion is correct. The old rule adds signed cast to both offset_b and offset_b, and does minus on them, as (stype)offset_a - (stype)offset_b Suppose that offset_a = (signed_int_max)UL, offset_b = 1UL, the trans will generate overflow result, while original computation will not. Alternative way is to add type cast after minus are done on offset_a and offset b. And to avoid unsigned overflow warning, we should add a view_convert instead of convert, which was missed in my patch. > Adding the TYPE_OVERFLOW_UNDEFINED guard also looks > odd - AFAICS overflow of the pointer type does not matter > but overflow of the generated minus? Thus at least > a || !TYPE_OVERFLOW_UNDEFINED (type) would be > in order? Yes, it is. will remove TYPE_OVERFLOW_UNDEFINED on pointer. Thanks, Feng