diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2017-08-30 04:20:23 +0200 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2018-03-18 19:02:28 +0100 |
| commit | 1609176c9dbddd280c20a49fce81c9e1dd9b9c78 (patch) | |
| tree | 8a22908818b9ab131f815b8a48febe0fc72b15e0 /validation/optim | |
| parent | a9a56d3994dfd86dbb5b74ab85b3709e4c3d4cee (diff) | |
| download | sparse-dev-1609176c9dbddd280c20a49fce81c9e1dd9b9c78.tar.gz | |
fix-return: remove special case for single return
During the linearization of a function, returns are directly
linearized as phi-sources and the exit BB contains the
corresponding phi-node and the unique OP_RET.
There is also a kind of optimization that is done if there is
only a single a return statement and thus a single phi-source:
the phi-source and the phi-node is simply ignored and the
unique value is directly used by the OP_RET instruction.
While this optimization make sense it also has some cons:
- the phi-node and the phi-source are created anyway and will
need to be removed during cleanup.
- the corresponding optimization need to be done anyway during
simplification
- it's only a tiny special case which save very litte.
So, keep things simple and generic and leave this sort of
simplification for the cleanup/simplification phase.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'validation/optim')
| -rw-r--r-- | validation/optim/inline-return.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/validation/optim/inline-return.c b/validation/optim/inline-return.c new file mode 100644 index 00000000..d075715d --- /dev/null +++ b/validation/optim/inline-return.c @@ -0,0 +1,24 @@ +static inline int def(void) +{ + return 1; +} + +int foo(void) +{ + return def(); +} + +int bar(void) +{ + return def(); + return 0; +} + +/* + * check-name: inline-return.c + * check-command: test-linearize -Wno-decl $file + * + * check-output-ignore + * check-output-pattern(2): ret\\..*\\$1 + * check-output-excludes: ret\\..*\\$0 + */ |
