[PATCH] D104410: GlobalISel/Utils: Add util function and matcher for constant splat

Petar Avramovic via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 17 02:22:25 PDT 2021


Petar.Avramovic added inline comments.


================
Comment at: llvm/include/llvm/CodeGen/GlobalISel/Utils.h:339
+/// When \p AllowUndef == true some elements can be undef but not all.
+Optional<Register> getVectorConstantSplatUndef(Register VReg,
+                                               const MachineRegisterInfo &MRI,
----------------
foad wrote:
> Would a return type of Optional<ValueAndVReg> (like getConstantVRegValWithLookThrough) be more useful? Actually I'm not sure if returning the register is useful, maybe just Optional<APInt>?
ValueAndVReg would be fine but in later patch APFloat would be useful. I did it with reg so that once it is matched caller knows if it matched int or float constant and can get APInt or APFloat and check what it needs.


================
Comment at: llvm/lib/CodeGen/GlobalISel/Utils.cpp:944
+    bool MatchFConstant, bool MatchIConstant) {
+  // Look through copies.
+  MachineInstr *MI;
----------------
foad wrote:
> Isn't there an existing utility you can call to do this?
There is code that does similar thing with look through in a few places but not a utility function. 


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

https://reviews.llvm.org/D104410



More information about the llvm-commits mailing list