[PATCH] D145327: [InstSimplify] Simplify `(shl nsw nuw X, BitWidth - 1)` -> `0`

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 6 05:39:10 PST 2023


spatel added inline comments.


================
Comment at: llvm/lib/Analysis/InstructionSimplify.cpp:1466
 
+  if (IsNSW && IsNUW && match(Op1, m_SpecificInt(Ty->getScalarSizeInBits() - 1)))
+    return Constant::getNullValue(Ty);
----------------
This could use an explanatory code comment, so we don't have to refer back to the no-wrap definitions:
  // "nuw" guarantees that only zeros are shifted out, and "nsw" guarantees 
  // that the sign-bit does not change, so the only input that does not 
  // produce poison is 0, and "0 << (bitwidth-1) --> 0".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145327



More information about the llvm-commits mailing list