[PATCH] D102711: [GlobalOpt] Handle null check with global pointer variables

Shimin Cui via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 19 12:49:13 PDT 2021


scui added inline comments.


================
Comment at: llvm/lib/Transforms/IPO/GlobalOpt.cpp:979
       case ICmpInst::ICMP_ULT:
       case ICmpInst::ICMP_SLT:   // X < null -> always false
         LV = ConstantInt::getFalse(GV->getContext());
----------------
efriedma wrote:
> Can we explicitly note here, for the signed compares, why it doesn't matter if the high bit of the global is set? The logic here isn't obvious.
I'm not sure what comments I can add,  as I actually don't know the logic here for the folding of the signed compares.  The code has been like this from 2009 (the earliest I can found). Do you have any suggestions on how to handle all these signed compares?


================
Comment at: llvm/lib/Transforms/IPO/GlobalOpt.cpp:988
       case ICmpInst::ICMP_NE:
       case ICmpInst::ICMP_UGE:
       case ICmpInst::ICMP_SGE:
----------------
efriedma wrote:
> UGE should fold to `ConstantInt::getTrue(GV->getContext());`
Right. 


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D102711/new/

https://reviews.llvm.org/D102711



More information about the llvm-commits mailing list