[llvm-dev] [InstCombine] Missed optimizations when null check before return statement

Dávid Bolvanský via llvm-dev llvm-dev at lists.llvm.org
Fri Apr 6 07:15:11 PDT 2018


Hello,

Please check code:
https://godbolt.org/g/wtimXj

Clang surprisingly generates worse code for common pattern
if (!ptr)
    return NULL;

than for
if (!ptr)
    return ptr;


Gcc generates same code.

I checked the InstCombine's code and tried something to fix it but no
success.
So I will leave this here for more skilled developers and maybe the could
fix this problem.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180406/d49d0798/attachment.html>


More information about the llvm-dev mailing list