Vect: avoid using uninitialized variable (PR tree-optimization/110531)

Message ID SJ2PR01MB863509CEB9A5B18AD42D986EE12EA@SJ2PR01MB8635.prod.exchangelabs.com
State Accepted
Headers
Series Vect: avoid using uninitialized variable (PR tree-optimization/110531) |

Checks

Context Check Description
snail/gcc-patch-check success Github commit url

Commit Message

Hao Liu OS July 4, 2023, 8:51 a.m. UTC
  slp_done_for_suggested_uf is used in vect_analyze_loop_2 without
initialization, which is undefined behavior.  Initialize it to false
according to the discussion.

gcc/ChangeLog:
        PR tree-optimization/110531
        * tree-vect-loop.cc (vect_analyze_loop_1): initialize
        slp_done_for_suggested_uf to false.
---
 gcc/tree-vect-loop.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Richard Biener July 4, 2023, 8:58 a.m. UTC | #1
On Tue, Jul 4, 2023 at 10:51 AM Hao Liu OS via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> slp_done_for_suggested_uf is used in vect_analyze_loop_2 without
> initialization, which is undefined behavior.  Initialize it to false
> according to the discussion.

OK

> gcc/ChangeLog:
>         PR tree-optimization/110531
>         * tree-vect-loop.cc (vect_analyze_loop_1): initialize
>         slp_done_for_suggested_uf to false.
> ---
>  gcc/tree-vect-loop.cc | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
> index f39a1ecb306..e504645f1df 100644
> --- a/gcc/tree-vect-loop.cc
> +++ b/gcc/tree-vect-loop.cc
> @@ -3333,7 +3333,7 @@ vect_analyze_loop_1 (class loop *loop, vec_info_shared *shared,
>    machine_mode vector_mode = vector_modes[mode_i];
>    loop_vinfo->vector_mode = vector_mode;
>    unsigned int suggested_unroll_factor = 1;
> -  bool slp_done_for_suggested_uf;
> +  bool slp_done_for_suggested_uf = false;
>
>    /* Run the main analysis.  */
>    opt_result res = vect_analyze_loop_2 (loop_vinfo, fatal,
> --
> 2.34.1
  

Patch

diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index f39a1ecb306..e504645f1df 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -3333,7 +3333,7 @@  vect_analyze_loop_1 (class loop *loop, vec_info_shared *shared,
   machine_mode vector_mode = vector_modes[mode_i];
   loop_vinfo->vector_mode = vector_mode;
   unsigned int suggested_unroll_factor = 1;
-  bool slp_done_for_suggested_uf;
+  bool slp_done_for_suggested_uf = false;
 
   /* Run the main analysis.  */
   opt_result res = vect_analyze_loop_2 (loop_vinfo, fatal,