simplify: conservative handling of casts with pointers
commit955cd225d2e3ee708e20de825eca82c8797897fd
authorJan Pokorný <pokorny_jan@seznam.cz>
Thu, 10 May 2012 10:07:47 +0000 (10 03:07 -0700)
committerChristopher Li <sparse@chrisli.org>
Thu, 10 May 2012 10:07:47 +0000 (10 03:07 -0700)
tree810055d62f0206440dc2132b69d109ae0186efb4
parent695dd9d068dd2316b92706d174df9e30c1e71dcf
simplify: conservative handling of casts with pointers

On 05/08/2012 04:13 PM, Jan Pokorný wrote:
> When the cast is optimized out/target pointer type information lost,
> it may be impossible for backend to recover it (think of
> "struct foo *my_new_foo = malloc(sizeof(*my_new_foo))").
>
> Losing such pointer type information can be wider issue (structs and
> unions maybe), but this is the most exposed one and the patch tries
> to be minimal in this regard and the impact seems to be minimal
> too as usually type-correctness is followed.

I expected that if both operands of the cast appear to be pointers, it is
always OP_PTRCAST case, which is not true.

So this version exchanges inequality test for "or".  Beside being
shorter, it covers such previously missed cases.

Based on asserts I experimented with, OP_PTRCASTs are always captured
by the condition implicitly (beside OP_CASTs with pointer-like operands).

Signed-off-by: Jan Pokorný <pokorny_jan@seznam.cz>
Signed-off-by: Christopher Li <sparse@chrisli.org>
simplify.c