[PATCH] D75280: [PowerPC][Future] Add initial support for PC Relative addressing for global values

Anil Mahmud via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 25 21:07:22 PDT 2020


anil9 added inline comments.


================
Comment at: llvm/lib/Target/PowerPC/PPCISelLowering.cpp:2545
 bool PPCTargetLowering::SelectAddressPCRel(SDValue N, SDValue &Base) const {
+  // This is a materialize PC Relative node. Always select this as PC Relative.
+  if (N.getOpcode() == PPCISD::MAT_PCREL_ADDR) {
----------------
nemanjai wrote:
> The logic might be easier to follow if we do something like:
> ```
> Base = N;
> if (N.getOpcode() == PPCISD::MAT_PCREL_ADDR)
>   return true;
> if (ConstantPoolSDNode *CPN = dyn_cast<ConstantPoolSDNode>(N) &&
>                               (CPN->getTargetFlags() & PPCII::MO_PCREL_FLAG))
>   return true;
> if (GlobalAddressSDNode *GAN = dyn_cast<GlobalAddressSDNode>(N) &&
>                                (GAN->getTargetFlags() & PPCII::MO_PCREL_FLAG))
>   return true;
> return false;
> ```
There is a slight change in logic with the above code. In the current implementation Base will not be set to N if the result is false, but with the code in the comment it will always be set to N. 




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

https://reviews.llvm.org/D75280





More information about the llvm-commits mailing list