[PATCH] D118351: [AMDGPU][GlobalISel] Code quality: don't expand G_BUILD_VECTOR_TRUNC if not neccessary

Matt Arsenault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 24 07:47:14 PST 2022


arsenm added inline comments.


================
Comment at: llvm/lib/Target/AMDGPU/AMDGPUPostLegalizerCombiner.cpp:322
+    if (MI.getOpcode() == TargetOpcode::G_LSHR) {
+      Register LshrCstReg = getDefIgnoringCopies(MI.getOperand(2).getReg(), MRI)
+                                ->getOperand(0)
----------------
Why use getDefIgnoringCopies instead of directly using mi_match?


================
Comment at: llvm/lib/Target/AMDGPU/AMDGPUPostLegalizerCombiner.cpp:386-396
+  // If the selected MachineInstruction is a G_BITCAST, the result will
+  // be the source of the bitcast.
+  // If not, build a bitcast that uses the dst of the selected
+  // MachineInstr.
+  if (SrcMI->getOpcode() == TargetOpcode::G_BITCAST) {
+    Reg = SrcMI->getOperand(1).getReg();
+    Helper.replaceRegWith(MRI, DstReg, Reg);
----------------
Special casing the use doesn't feel right. If the type doesn't match, insert a new cast and rely on bitcast folding?


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

https://reviews.llvm.org/D118351



More information about the llvm-commits mailing list