[PATCH] D25785: [InstSimplify] folds for negation of sign-bit

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 19 13:56:10 PDT 2016

spatel added inline comments.

Comment at: lib/Analysis/InstructionSimplify.cpp:692
+    APInt KnownOne(BitWidth, 0);
+    computeKnownBits(Op1, KnownZero, KnownOne, Q.DL, 0, Q.AC, Q.CxtI, Q.DT);
+    if (KnownZero == ~APInt::getSignBit(BitWidth)) {
efriedma wrote:
> I'm sort of concerned that calling computeKnownBits here could lead to compile-time performance problems, given that instsimplify is supposed to be inexpensive, and the condition is very unlikely to succeed in most code.  I don't have any evidence it's actually an issue, though; maybe computeKnownBits is cheap enough that it doesn't matter.
Yes, I wasn't sure about doing a specific match for 'and' or 'shl' instead. I saw that we are using computeKnownBits in other places in this file though, so I thought it would be ok.


More information about the llvm-commits mailing list