https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127645

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pinskia at gcc dot gnu.org

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
Seems like CSELIM and _Bool go wrong in some way.  We have a conditional change
of the active union member, but

    c12 = v15;
    g18 = c12 ? g18 : (union u0){ .f2 = 1 };
    if (g18.f1 == 45) return 0;

with v15 == 0 activates .f2 (does it?) and then reads .f1, so this might be
invoking UB.

Still CSELIM does

+  bool _16;
+  bool _17;

   __BB(2,guessed_local(118111600)):
   _1 = g1;
@@ -32,15 +74,17 @@
   g18.f1 = _Literal (uint8_t) 45;
   c12_14 = v15_6 != 0ul;
   if (v15_6 != 0ul)
-    goto __BB7(guessed(67108864));
-  else
     goto __BB6(guessed(67108864));
+  else
+    goto __BB7(guessed(67108864));

   __BB(6,guessed_local(536870912)):
-  g18.f2 = _Literal (bool) 1;
+  _16 = __MEM <union u0> ((void *)&g18).f2;
   goto __BB7(precise(134217728));

   __BB(7,guessed_local(1073741824)):
+  _17 = __PHI (__BB5: _Literal (bool) 1, __BB6: _16);
+  __MEM <union u0> ((void *)&g18).f2 = _17;
   _4 = g18.f1;

so unconditionally activates .f2 which should be avoided.  The full original
IL is

  __BB(5,guessed_local(1073741824)):
  g18.f1 = _Literal (uint8_t) 45;
  c12_14 = v15_6 != 0ul;
  if (v15_6 != 0ul)
    goto __BB7(guessed(67108864));
  else
    goto __BB6(guessed(67108864));

  __BB(6,guessed_local(536870912)):
  g18.f2 = _Literal (bool) 1;
  goto __BB7(precise(134217728));

  __BB(7,guessed_local(1073741824)):
  _4 = g18.f1;

Reply via email to