@@ -30,8 +30,6 @@ static inline bool is_promotable(struct symbol *type)
case SYM_RESTRICT: // OK, always integer types
return 1;
case SYM_STRUCT:
- if (type->bit_size > long_ctype.bit_size)
- return 0;
// we allow a single scalar field
// but a run of bitfields count for 1
nbr = 0;
@@ -49,6 +47,8 @@ static inline bool is_promotable(struct symbol *type)
if (nbr++)
return 0;
} END_FOR_EACH_PTR(member);
+ if (bf_seen && (type->bit_size > long_ctype.bit_size))
+ return 0;
return 1;
case SYM_UNION:
// FIXME: should be like struct but has problem
@@ -21,8 +21,6 @@ double sdouble(void)
/*
* check-name: init-local32
* check-command: test-linearize -Wno-decl -m32 -fdump-ir=mem2reg $file
- * check-known-to-fail
- *
* check-output-ignore
* check-output-excludes: load\\.
* check-output-excludes: store\\.
During SSA conversion, it is checked what can be promoted and what cannot. Obviously, ints, longs, pointers can be promoted, enums and bitfields can too. Complication arise with unions and structs. Currently union are only accepted if they contains integers of the same size. For structs its even more complicated because we want to convert simple bitfields. What should be accepted is structs containing either: * a single scalar * only bitfields and only if the total size is < long However the test was slightly more strict than that: it dodn't allowed a struct with a total size bigger than a long. As consequence, on IP32, a struct containing a single double wasn't promoted. Fix this by moving the test about the total size and only if some bitfield was present. Reported-by: Ramsay Jones <ramsay@ramsayjones.plus.com> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com> --- ssa.c | 4 ++-- validation/mem2reg/init-local32.c | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-)