diff options
| -rw-r--r-- | simplify.c | 4 | ||||
| -rw-r--r-- | validation/cast-kinds.c | 12 | ||||
| -rw-r--r-- | validation/fp2i-cast.c | 30 |
3 files changed, 42 insertions, 4 deletions
@@ -944,6 +944,10 @@ 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)) + return 0; + orig_size = orig_type->bit_size; size = insn->size; src = insn->src; diff --git a/validation/cast-kinds.c b/validation/cast-kinds.c index 697f9735..e686c01e 100644 --- a/validation/cast-kinds.c +++ b/validation/cast-kinds.c @@ -92,7 +92,8 @@ iptr_2_int: float_2_int: .L10: <entry-point> - ret.32 %arg1 + cast.32 %r17 <- (32) %arg1 + ret.32 %r17 double_2_int: @@ -139,7 +140,8 @@ iptr_2_uint: float_2_uint: .L24: <entry-point> - ret.32 %arg1 + cast.32 %r38 <- (32) %arg1 + ret.32 %r38 double_2_uint: @@ -193,7 +195,8 @@ float_2_long: double_2_long: .L40: <entry-point> - ret.64 %arg1 + cast.64 %r62 <- (64) %arg1 + ret.64 %r62 int_2_ulong: @@ -240,7 +243,8 @@ float_2_ulong: double_2_ulong: .L54: <entry-point> - ret.64 %arg1 + cast.64 %r83 <- (64) %arg1 + ret.64 %r83 int_2_vptr: diff --git a/validation/fp2i-cast.c b/validation/fp2i-cast.c new file mode 100644 index 00000000..08f8c925 --- /dev/null +++ b/validation/fp2i-cast.c @@ -0,0 +1,30 @@ +#if __SIZEOF_INT__ == __SIZEOF_FLOAT__ +typedef signed int si; +typedef unsigned int ui; +#else +#error "no float-sized integer type" +#endif + +#if __SIZEOF_LONG_LONG__ == __SIZEOF_DOUBLE__ +typedef signed long long sl; +typedef unsigned long long ul; +#else +#error "no double-sized integer type" +#endif + +si f2si(float a) { return a; } +ui f2ui(float a) { return a; } +sl f2sl(float a) { return a; } +ul f2ul(float a) { return a; } +si d2si(double a) { return a; } +ui d2ui(double a) { return a; } +sl d2sl(double a) { return a; } +ul d2ul(double a) { return a; } + +/* + * check-name: fp2i cast + * check-command: test-linearize -Wno-decl $file + * + * check-output-ignore + * check-output-pattern-8-times: cast\\. + */ |
