[PATCH] D129838: [LoongArch] Optimize the atomic store with amswap_db.[w/d]
Gong LingQin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 19 01:28:11 PDT 2022
gonglingqin added inline comments.
================
Comment at: llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp:1741
+ return isa<LoadInst>(I) || isa<StoreInst>(I);
+ } else {
+ unsigned Size = 0;
----------------
SixWeining wrote:
> No need to use `else` after `return`.
Thanks.
================
Comment at: llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp:1742-1744
+ unsigned Size = 0;
+ if (isa<StoreInst>(I))
+ Size = I->getOperand(0)->getType()->getIntegerBitWidth();
----------------
SixWeining wrote:
> SixWeining wrote:
> > Size = isa<StoreInst>(I) ? I->getOperand(0)->getType()->getIntegerBitWidth() : 0;
> How about:
> ```
> if (isa<LoadInst>(I))
> return true;
>
> // On LA64, atomic store operations with IntegerBitWidth of 32 and 64 do not
> // require fences beacuse we can use amswap_db.[w/d].
> if (isa<StoreInst>(I)) {
> unsigned Size = I->getOperand(0)->getType()->getIntegerBitWidth();
> return (Size == 8 || Size == 16);
> }
>
> return false;
> ```
Thanks.
================
Comment at: llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp:1742-1748
+ unsigned Size = 0;
+ if (isa<StoreInst>(I))
+ Size = I->getOperand(0)->getType()->getIntegerBitWidth();
+ // On LA64, atomic store operations with IntegerBitWidth of 32 and 64 do not
+ // require fences beacuse we can use amswap_db.[w/d].
+ return isa<LoadInst>(I) || (isa<StoreInst>(I) && (Size == 8 || Size == 16));
+ }
----------------
gonglingqin wrote:
> SixWeining wrote:
> > SixWeining wrote:
> > > Size = isa<StoreInst>(I) ? I->getOperand(0)->getType()->getIntegerBitWidth() : 0;
> > How about:
> > ```
> > if (isa<LoadInst>(I))
> > return true;
> >
> > // On LA64, atomic store operations with IntegerBitWidth of 32 and 64 do not
> > // require fences beacuse we can use amswap_db.[w/d].
> > if (isa<StoreInst>(I)) {
> > unsigned Size = I->getOperand(0)->getType()->getIntegerBitWidth();
> > return (Size == 8 || Size == 16);
> > }
> >
> > return false;
> > ```
> Thanks.
Thanks, I will change it.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D129838/new/
https://reviews.llvm.org/D129838
More information about the llvm-commits
mailing list