Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tree-ssa-strlen] missing strlen optimization for strcmp of unequal strings #15

Open
xiangzhai opened this issue Jan 23, 2018 · 0 comments
Labels
Milestone

Comments

@xiangzhai
Copy link

Hi fellows,

As PR83026 mentioned:
Testcase:

$ cat c.c
void g (const char *a, const char *b)
{
  if (__builtin_strlen (a) == __builtin_strlen (b))
    return;

  if (!__builtin_strcmp (a, b))
    __builtin_abort ();
}

GCC 5.5 and 8.x failed to fold:

if (!__builtin_strcmp (a, b))
    __builtin_abort ();

might be optimized to:

<bb 4> [count: 0]:
  __builtin_abort ();

Without:

<bb 3> [local count: 7903]:
  _3 = __builtin_strcmp (a_5(D), b_6(D));
  if (_3 == 0)
    goto <bb 4>; [0.04%]
  else
    goto <bb 5>; [99.96%]

Qing Zhao is on it 👍

Regards,
Leslie Zhai

@xiangzhai xiangzhai added the bug label Jan 23, 2018
@xiangzhai xiangzhai added this to the gcc-8-branch milestone Feb 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant