diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-06-18 11:49:03 +0200 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-06-26 14:01:50 +0200 |
| commit | 1ed0dfb473629202784f9701991671a6f9c6ff6e (patch) | |
| tree | a72f796ba6d173eed9ac585363fb41ff097f1b06 /validation | |
| parent | 4d851248702bebe6c8ecdd1cef54e7782c72b8a2 (diff) | |
| download | sparse-dev-1ed0dfb473629202784f9701991671a6f9c6ff6e.tar.gz | |
cast: simplify TRUNC + ZEXT to AND
A truncation followed by a zero-extension to the original size,
which is produced when loading a storing bitfields, is equivalent
to a simple AND masking. Often, this AND can then trigger even
more optimizations.
So, replace TRUNC + ZEXT instructions by the equivalent AND.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'validation')
| -rw-r--r-- | validation/optim/bitfield-init-zero.c (renamed from validation/linear/bitfield-init-zero.c) | 12 | ||||
| -rw-r--r-- | validation/optim/bitfield-size.c (renamed from validation/bitfield-size.c) | 6 |
2 files changed, 8 insertions, 10 deletions
diff --git a/validation/linear/bitfield-init-zero.c b/validation/optim/bitfield-init-zero.c index 16422c19..e619d1d2 100644 --- a/validation/linear/bitfield-init-zero.c +++ b/validation/optim/bitfield-init-zero.c @@ -57,8 +57,7 @@ int bfs_get0(void) bfuu_init: .L0: <entry-point> - trunc.9 %r2 <- (32) %arg1 - zext.32 %r4 <- (9) %r2 + and.32 %r4 <- %arg1, $511 shl.32 %r5 <- %r4, $11 ret.32 %r5 @@ -66,8 +65,7 @@ bfuu_init: bfus_init: .L2: <entry-point> - trunc.9 %r11 <- (32) %arg1 - zext.32 %r13 <- (9) %r11 + and.32 %r13 <- %arg1, $511 shl.32 %r14 <- %r13, $11 ret.32 %r14 @@ -81,8 +79,7 @@ bfu_get0: bfsu_init: .L6: <entry-point> - trunc.9 %r25 <- (32) %arg1 - zext.32 %r27 <- (9) %r25 + and.32 %r27 <- %arg1, $511 shl.32 %r28 <- %r27, $11 ret.32 %r28 @@ -90,8 +87,7 @@ bfsu_init: bfss_init: .L8: <entry-point> - trunc.9 %r34 <- (32) %arg1 - zext.32 %r36 <- (9) %r34 + and.32 %r36 <- %arg1, $511 shl.32 %r37 <- %r36, $11 ret.32 %r37 diff --git a/validation/bitfield-size.c b/validation/optim/bitfield-size.c index a39c3966..0d2deeea 100644 --- a/validation/bitfield-size.c +++ b/validation/optim/bitfield-size.c @@ -35,8 +35,10 @@ unsigned int get_pbfi_b(struct bfi *bf) { return bf->b; } * check-command: test-linearize -Wno-decl $file * check-output-ignore * - * check-output-pattern(8): zext\\. + * check-output-excludes: and\\..*\\$960 + * check-output-excludes: zext\\. + * check-output-pattern(8): and\\..*\\$15 * check-output-pattern(4): sext\\. - * check-output-pattern(12): trunc\\.4 + * check-output-pattern(4): trunc\\.4 * check-output-pattern(6): lsr\\..*\\$6 */ |
