[PATCH] D84250: [InstSimplify] ExpandBinOp should fold an expression only when it's safe

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 24 11:03:36 PDT 2020


spatel added a comment.

We need some tests pre-committed within InstSimplify to show this working (disabling simplify) for each opcode?



================
Comment at: llvm/lib/Analysis/InstructionSimplify.cpp:231-234
+// CanFoldToConstantUsingOneOperand returns a constant after folding "L Op R"
+// after using only one of L or R, but not both.
+// Formally, it returns a constant X s.t. "L Op Y --> X" or "Y Op R --> X" holds
+//   for any Y (E --> V stands for simplifying E to V).
----------------
Could we adapt this existing analysis function?
  /// Return the absorbing element for the given binary
  /// operation, i.e. a constant C such that X op C = C and C op X = C for
  /// every X.  For example, this returns zero for integer multiplication.
  /// It returns null if the operator doesn't have an absorbing element.
  static Constant *getBinOpAbsorber(unsigned Opcode, Type *Ty);



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84250





More information about the llvm-commits mailing list