[llvm-dev] Path condition propagation

Carlos Liam via llvm-dev llvm-dev at lists.llvm.org
Thu Jun 30 18:09:29 PDT 2016


Hi all,

Consider this C code:

#include <stdbool.h>

bool func(int n1, int n2, bool b) {
    bool greater = n1 > n2;
    if (greater && b) {
        if (n1 == n2) {
            return false; // unreachable
        }
    }
    return true;
}

The line marked unreachable cannot be reached, however currently LLVM does not optimize it out. I believe this is because LLVM does not recognize that meeting path conditions like, for example, X && Y logically means that X is true and Y is true.

I'm interested in creating a patch to remedy this; is there a file or function I should look at?

Thanks in advance.

 - CL


More information about the llvm-dev mailing list