diff options
author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-09-09 23:40:01 +0200 |
---|---|---|
committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-09-10 00:55:00 +0200 |
commit | e5cbdb62b0e3dc49244dfbcbe90f5fe5ea370a05 (patch) | |
tree | 7941d96b8eb7ace4bfbca6ed98093cac44323b94 | |
parent | 6c522d114cef173215686b3394ae41701ea80aa4 (diff) | |
download | sparse-e5cbdb62b0e3dc49244dfbcbe90f5fe5ea370a05.tar.gz |
ssa: relax what can be promoted
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>
-rw-r--r-- | ssa.c | 4 | ||||
-rw-r--r-- | validation/mem2reg/init-local32.c | 2 |
2 files changed, 2 insertions, 4 deletions
@@ -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 diff --git a/validation/mem2reg/init-local32.c b/validation/mem2reg/init-local32.c index c988bb6e..9a65c205 100644 --- a/validation/mem2reg/init-local32.c +++ b/validation/mem2reg/init-local32.c @@ -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\\. |