[PATCH] D41554: [InstSimplify] Missed optimization in math expression: (x+x)/x == 2

Noel Grandin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 24 03:23:54 PST 2017


grandinj added inline comments.


================
Comment at: lib/Analysis/InstructionSimplify.cpp:997
+  if ((IsSigned && match(Op0, m_NSWShl(m_Specific(Op1), m_One()))) ||
+      (!IsSigned && match(Op0, m_Shl(m_Specific(Op1), m_One())))) {
+    return ConstantInt::get(Op0->getType(), 2);
----------------
majnemer wrote:
> I believe this needs to be m_NUWShl.
Is that not trivially extendable to 

    (X << C) / X -> C

for any 

    C <= bitwidth(X)

?


https://reviews.llvm.org/D41554





More information about the llvm-commits mailing list