[PATCH] [Reassociate] Better preserve NSW/NUW flags. (PR12985)

David Majnemer david.majnemer at gmail.com
Fri Nov 7 12:33:21 PST 2014


================
Comment at: lib/Transforms/Scalar/Reassociate.cpp:1039-1045
@@ +1038,9 @@
+
+  // We can safely preserve the nuw flag in all cases.  It's also safe to turn a
+  // nuw nsw shl into a nuw nsw mul.  However, nsw in isolation requires special
+  // handling.
+  bool NSW = cast<BinaryOperator>(Shl)->hasNoSignedWrap();
+  bool NUW = cast<BinaryOperator>(Shl)->hasNoUnsignedWrap();
+  if (NUW)
+    Mul->setHasNoSignedWrap(NSW);
+  Mul->setHasNoUnsignedWrap(NUW);
----------------
Shouldn't this be:
  if (NSW && NUW)

?

http://reviews.llvm.org/D6172






More information about the llvm-commits mailing list