A integer-to-float cast of a constant is currently simplified away as if it is an integer-to-integer cast. That's bad. Fix this by refusing to simplify away any integer-to-float casts like already done for float-to-integer casts. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx> --- simplify.c | 4 ++-- validation/optim/fpcast-constant.c | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/simplify.c b/simplify.c index be7208608..ccf0a5f5e 100644 --- a/simplify.c +++ b/simplify.c @@ -955,8 +955,8 @@ static int simplify_cast(struct instruction *insn) if (is_ptr_type(orig_type) || is_ptr_type(insn->type)) return 0; - /* Keep float-to-int casts */ - if (is_float_type(orig_type) && !is_float_type(insn->type)) + /* Keep float-to-int and int-to-float casts */ + if (is_float_type(orig_type) != is_float_type(insn->type)) return 0; orig_size = orig_type->bit_size; diff --git a/validation/optim/fpcast-constant.c b/validation/optim/fpcast-constant.c index 47feffe5f..c0f906b39 100644 --- a/validation/optim/fpcast-constant.c +++ b/validation/optim/fpcast-constant.c @@ -6,7 +6,6 @@ static double foo(double a, int p) /* * check-name: fpcast-constant * check-command: test-linearize $file - * check-known-to-fail * * check-output-ignore * check-output-contains: fpcast\\. -- 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