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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rguenth at gcc dot gnu.org
          Component|other                       |tree-optimization
         Depends on|                            |86554

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
The following culd be massaged into a testcase:

int flag;
union { float f; int i; } u;
int main()
{
  if (flag)
    __builtin_printf("%d", u.i);
  else
    __builtin_printf("%f", u.f);
  return 0;
}

It is PRE / code hoisting that hoists the loaded value (and it chooses the
float variant).  -fno-code-hoisting should mitigate this.  PR86554 is a
related issue.

main ()
{
  int flag.0_1;
  double _4;
  float pretmp_10;
  int _11;

  <bb 2> [100.00%]:
  flag.0_1 = flag;
  pretmp_10 = u.f;
  if (flag.0_1 != 0)
    goto <bb 3>; [46.00%]
  else
    goto <bb 4>; [54.00%]

  <bb 3> [46.00%]:
  _11 = VIEW_CONVERT_EXPR<int>(pretmp_10);
  __builtin_printf ("%d", _11);
  goto <bb 5>; [100.00%]

  <bb 4> [54.00%]:
  _4 = (double) pretmp_10;
  __builtin_printf ("%f", _4);


Given the intention of the optimization is to CSE loading the memory contents
and we elsewhere avoid using floats for such operation the bug is probably
valid.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86554
[Bug 86554] [7/8/9 Regression] Incorrect code generation with signed/unsigned
comparison

Reply via email to