[PATCH] D96013: GlobalISel: Try to combine G_[SU]DIV and G_[SU]REM

Matt Arsenault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 12 15:00:29 PST 2021


arsenm added inline comments.


================
Comment at: llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp:1026
+  MI.eraseFromParent();
+  OtherMI->eraseFromParent();
+}
----------------
cdevadas wrote:
> arsenm wrote:
> > I'm worried about what happens if multiple div/rem users exist. Can you add some tests for that?
> This patch currently performs a one-to-one match. It doesn't look for multiple div/rem users. 
> For example, it won't optimally match the following pattern: 
> G_SDIV x, y, G_SREM x, y and an extra G_SDIV x, y
> The first div/rem pair will be combined and the second div will be retained.
> Instead, it should have generated d, r = G_SDIVREM x, y ;  replace all users of the second G_SDIV with 'd' and then delete the extra G_SDIV as well.
> I will rework this part.
> 
I don't think this should be collecting a vector of other instructions and looking  for redundant div/rems. It just needs to not crash if one of these extras exist


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96013



More information about the llvm-commits mailing list