The goal of this series is to specialize the few cast instructions into more specialized ones so that their precise nature is fully specified by the instructions thmeselves so that no additional checks need to ne done later (like having to check the source or target type is signed or not, integer or float, ...). With this series we have: - TRUNC, for int to smaller size int - ZEXT, for int to bigger int with zero extend - SEXT, for int to bigger int with sign extend - PTRTU, for pointer to same sized [unsigned] int - UTPTR, for pointer from same sized [unsigned] int - PTRCAST, for pointer to pointer - FCVT[US], for float to unsigned/signed integer - [US]CVTF, for float from unsigned/signed integer - FCVTF, for float to float Also: - for these casts, void pointers are treated as unsigned integers - casts from int to same sized int are trated as NOP and never generated. There are few other changes that may be needed later, like: - maybe we should no drop the NOPs and have a real NOPCAST ? - this NOPCAST may then be used for floats and pointers too? - this NOPCAST could then be simplified away when needed - PTRTU & UTPTR are in the same situation: - are they needed? - when can we simplified them away? - it may be good to split FCVTF into: FTRUNC, NOPCAST & FPEXT - is it still good to treat void pointers the same as integers? The series is available for testing & review in the Git repository at: git://github.com/lucvoo/sparse-dev.git cast-rework before it will be 'promoted' to the master tree at git://github.com/lucvoo/sparse.git master ---------------------------------------------------------------- Luc Van Oostenryck (20): cast: reorg testcases related to casts cast: add testcase for bad implicit casts to struct/union cast: add testcase for cast to bad typeof cast: add tests for warnings issued by sparse -v cast: rename evaluate_cast()'s vars with slightly more meaningful names cast: force_cast are OK on non-scalar values cast: prepare finer grained cast instructions cast: specialize FPCAST into [USF]CVTF cast: handle NO-OP casts cast: specialize floats to integer conversion cast: specialize casts from unsigned to pointers cast: make [u]intptr_ctype alias of [s]size_t_ctype cast: make pointer casts always size preserving cast: temporary simplify handling cast to/from void* cast: specialize cast from pointers cast: add support for -Wpointer-to-int-cast cast: make casts from pointer always size preserving cast: specialize integer casts cast: accept null casts cast: do not try to linearize illegal casts Documentation/IR.rst | 38 +++- cse.c | 10 +- evaluate.c | 104 +++++------ example.c | 22 ++- lib.c | 4 + lib.h | 2 + linearize.c | 175 ++++++++++++++--- linearize.h | 11 +- liveness.c | 10 +- simplify.c | 54 +++--- sparse-llvm.c | 57 ++++-- sparse.c | 5 +- symbol.h | 3 + validation/backend/pointer-sub.c | 2 +- validation/bitfield-size.c | 5 +- validation/bool-cast-explicit.c | 22 --- validation/bool-cast-implicit.c | 25 --- validation/builtin-bswap-variable.c | 4 +- validation/cast-bad-00.c | 47 +++++ validation/cast-bad-01.c | 13 ++ validation/cast-kinds-check.c | 19 ++ validation/cast-weirds.c | 51 +++++ validation/compound-assign-type.c | 3 +- validation/expand/builtin-expect.c | 8 +- validation/linear/bitfield-init-zero.c | 8 +- validation/linear/bool-cast-lp32.c | 19 ++ validation/linear/bool-cast-lp64.c | 18 ++ validation/linear/bool-cast.c | 36 ++++ validation/linear/call-basic.c | 4 +- .../{ => linear}/cast-constant-to-float.c | 0 validation/{ => linear}/cast-constants.c | 0 validation/{ => linear}/cast-kinds.c | 176 ++++++++++-------- validation/linear/cast-volatile.c | 5 +- validation/{ => linear}/fp-vs-ptrcast.c | 0 validation/{ => linear}/fp2i-cast.c | 3 +- validation/optim/bool-simplify.c | 4 +- validation/optim/canonical-cmp.c | 72 +++---- validation/{ => optim}/kill-casts.c | 5 + 38 files changed, 728 insertions(+), 316 deletions(-) delete mode 100644 validation/bool-cast-explicit.c delete mode 100644 validation/bool-cast-implicit.c create mode 100644 validation/cast-bad-00.c create mode 100644 validation/cast-bad-01.c create mode 100644 validation/cast-kinds-check.c create mode 100644 validation/cast-weirds.c create mode 100644 validation/linear/bool-cast-lp32.c create mode 100644 validation/linear/bool-cast-lp64.c create mode 100644 validation/linear/bool-cast.c rename validation/{ => linear}/cast-constant-to-float.c (100%) rename validation/{ => linear}/cast-constants.c (100%) rename validation/{ => linear}/cast-kinds.c (66%) rename validation/{ => linear}/fp-vs-ptrcast.c (100%) rename validation/{ => linear}/fp2i-cast.c (89%) rename validation/{ => optim}/kill-casts.c (63%) -- 2.17.1 -- To unsubscribe from this list: send the line "unsubscribe linux-sparse" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html