[LLVMdev] [cfe-dev] Disable Short-Circuit Evaluation?
annulen at yandex.ru
Mon Oct 10 08:19:04 PDT 2011
10.10.2011, 18:29, "David A. Greene" <greened at obbligato.org>:
> Justin Holewinski <justin.holewinski at gmail.com> writes:
>> int globalIndexY2 = get_group_id(1)*186 + 6*get_local_id(1) + 2 + 1;
>> bool valid2 = validX && globalIndexY2 >= 4 && globalIndexY2 < 3910;
>> Clang, even at -O0, is performing short-circuit evaluation of these
>> expressions, resulting in a fair number of branch instructions being
> It has to. This is the semantics of C. Short-circuiting is used to
> defend against all sorts of undefined behavior in real code.
More precisely, && and || are sequence points (though in C++ they may not be
sequence points if respective operator is overloaded)
More information about the llvm-dev