[PATCH] D103326: [GlobalISel] Add combine for PTR_ADD with regbanks

Jay Foad via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 1 02:21:07 PDT 2021


foad added a comment.

In D103326#2830327 <https://reviews.llvm.org/D103326#2830327>, @sebastian-ne wrote:

> I now added two helper function in CombinerHelper,
> `getRegBankId` returns an `Optional<unsigned>` for a register and
> `setRegBankId` sets such an optional bank to a register (or does nothing it it’s None).

Why use an optional ID, instead of just a RegisterBank pointer that may be null? Is it just to make it more obvious that setRegBankId(None) should do nothing?



================
Comment at: llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp:148
+  const RegisterBank *Bank = RBI->getRegBank(Reg, MRI, *TRI);
+  if (Bank)
+    return Bank->getID();
----------------
Doesn't matter of course, but you could use `?:` here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D103326



More information about the llvm-commits mailing list