[cfe-dev] Disable Short-Circuit Evaluation?
Justin Holewinski
justin.holewinski at gmail.com
Mon Oct 10 06:27:53 PDT 2011
Is there any way to disable short-circuit evaluation of expressions in
Clang/LLVM?
Let's say I have C code like the following:
bool validX = get_group_id(0) > 32;
int globalIndexY0 = get_group_id(1)*186 + 6*get_local_id(1) + 0 + 1;
bool valid0 = validX && globalIndexY0 >= 4 && globalIndexY0 < 3910;
int globalIndexY1 = get_group_id(1)*186 + 6*get_local_id(1) + 1 + 1;
bool valid1 = validX && globalIndexY1 >= 4 && globalIndexY1 < 3910;
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
generated. For most targets, this is a beneficial optimizations. However,
for my target (PTX), it would be most beneficial to actually evaluate the
entire expression and remove the unneeded branches. Is this possible with
current Clang/LLVM?
--
Thanks,
Justin Holewinski
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20111010/9f7000e3/attachment.html>
More information about the cfe-dev
mailing list