[PATCH] D83671: GlobalISel: Implement widenScalar for saturating add/sub

Matt Arsenault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 13 06:46:24 PDT 2020


arsenm marked an inline comment as done.
arsenm added inline comments.


================
Comment at: llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp:1671
+
+  auto Result = IsSigned ? MIRBuilder.buildAShr(WideTy, WideInst, ShiftK)
+                         : MIRBuilder.buildLShr(WideTy, WideInst, ShiftK);
----------------
foad wrote:
> arsenm wrote:
> > foad wrote:
> > > There's no need to make this conditional on IsSigned if we're just about to truncate anyway.
> > How else would I know whether to prefer ashr or lshr?
> Why would it make any difference? Can't you just pick one arbitrarily?
First I don't know whether the target has a reason to prefer one over the other. I also would assume using the right shift to preserve the expected number of sign bits for the signed result would be more useful for downstream simplifications once the trunc is folded out


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

https://reviews.llvm.org/D83671





More information about the llvm-commits mailing list