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

LLVM does not understand that inequality is transitive (even with constraint-elimination) #53273

Closed
jrmuizel opened this issue Jan 18, 2022 · 4 comments

Comments

@jrmuizel
Copy link

GCC is able to eliminate the third assert in the following code:

#include <assert.h>
void f(int a, int b, int c) {
    assert(a < b);
    assert(b < c);
    assert(a < c);
}

https://gcc.godbolt.org/z/s9a9YM6GK

However, if I change the type from int to unsigned int LLVM is able to figure it out.

@thvdveld
Copy link

thvdveld commented Jan 19, 2022

Looks like gcc 11.2 cannot eliminate the third assert when using unsigned int.
https://gcc.godbolt.org/z/Ph3bqjzbq

gcc 12 can do both.

@fhahn
Copy link
Contributor

fhahn commented Feb 2, 2022

The reason this is not handled by constraint-elimination is that support for signed conditions is not available on main yet. I put up a patch for initial signed support: https://reviews.llvm.org/D118806

@fhahn
Copy link
Contributor

fhahn commented Feb 4, 2022

Initial signed support landed in 0a781d9

@jrmuizel
Copy link
Author

This seems fixed now.
https://gcc.godbolt.org/z/s9a9YM6GK

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants