[PATCH] D123399: [InstCombine] Fold sub(add(x,y),min/max(x,y)) -> max/min(x,y) (PR38280)

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 8 12:14:46 PDT 2022


nikic added a comment.

LoopVectorize failures looks related.

> My main query is whether we need any oneuse limits or not - the only case where we don't see any reduction in instructions is if both the add + min/max have other uses, where we then replace a sub with a max/min intrinsic, which is probably going too far - any thoughts?

I'd probably limit the minmax intrinsic to one use, to avoid creating two of those.



================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp:2014
+    // sub(add(X,Y), s/umax(X,Y)) --> s/umin(X,Y)
+    // TODO: generalize to sub(add(Z,Y),umin(X,Y)) --> add(Z,usub.sat(Y,X))?
+    Value *X, *Y;
----------------
Use MinMaxIntrinsic + getInverseMinMaxIntrinsic() rather than enumerating cases?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123399



More information about the llvm-commits mailing list