diff options
author | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2018-03-08 07:29:42 +0000 |
---|---|---|
committer | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2018-03-08 07:29:42 +0000 |
commit | 48723ae9a8283d650e9690c4a3ef1efec3f4bbe9 (patch) | |
tree | 61dc23f5b9e429cfa27f5a1b470df71301004c45 | |
parent | 8b84a61218a2dd83111889846d74005d8e727954 (diff) | |
download | gcc-48723ae9a8283d650e9690c4a3ef1efec3f4bbe9.tar.gz |
PR tree-optimization/84740
* tree-switch-conversion.c (process_switch): Call build_constructors
only if info.phi_count is non-zero.
* gcc.dg/torture/pr84740.c: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@258354 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/torture/pr84740.c | 24 | ||||
-rw-r--r-- | gcc/tree-switch-conversion.c | 3 |
4 files changed, 33 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c96e895c3d8..39587da2e84 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,9 @@ 2018-03-08 Jakub Jelinek <jakub@redhat.com> + PR tree-optimization/84740 + * tree-switch-conversion.c (process_switch): Call build_constructors + only if info.phi_count is non-zero. + PR tree-optimization/84739 * tree-tailcall.c (find_tail_calls): Check call arguments against DECL_ARGUMENTS (current_function_decl) rather than diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3f0ac96471a..a42a376c6df 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2018-03-08 Jakub Jelinek <jakub@redhat.com> + PR tree-optimization/84740 + * gcc.dg/torture/pr84740.c: New test. + PR tree-optimization/84739 * gcc.dg/pr84739.c: New test. diff --git a/gcc/testsuite/gcc.dg/torture/pr84740.c b/gcc/testsuite/gcc.dg/torture/pr84740.c new file mode 100644 index 00000000000..8fcc028298f --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr84740.c @@ -0,0 +1,24 @@ +/* PR tree-optimization/84740 */ + +void +frobulate_for_gcc (unsigned int v) +{ + const char *s; + switch (v) + { + case 0: + s = "foo"; + break; + case 1: + s = "bar"; + break; + case 2: + s = "spam"; + break; + default: + s = (const char *) 0; + break; + } + if (!s) + __builtin_printf ("%s\n", s); +} diff --git a/gcc/tree-switch-conversion.c b/gcc/tree-switch-conversion.c index c2538908340..2da7068345c 100644 --- a/gcc/tree-switch-conversion.c +++ b/gcc/tree-switch-conversion.c @@ -1563,7 +1563,8 @@ process_switch (gswitch *swtch) gather_default_values (info.default_case_nonstandard ? gimple_switch_label (swtch, 1) : gimple_switch_default_label (swtch), &info); - build_constructors (swtch, &info); + if (info.phi_count) + build_constructors (swtch, &info); build_arrays (swtch, &info); /* Build the static arrays and assignments. */ gen_inbound_check (swtch, &info); /* Build the bounds check. */ |