[PATCH] D21493: [ValueTracking] Teach computeKnownBits for PHI nodes to compute sign bit for a recurrence with a NSW addition.
Sanjoy Das via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 20 12:38:04 PDT 2016
sanjoy added inline comments.
================
Comment at: lib/Analysis/ValueTracking.cpp:1251
@@ +1250,3 @@
+ KnownZero.setBit(BitWidth-1);
+ if (KnownOne2.isNegative() && KnownOne3.isNegative())
+ KnownOne.setBit(BitWidth-1);
----------------
craig.topper wrote:
> sanjoy wrote:
> > Can you please add a test for this second bit (i.e. negative stays negative)?
> Do you have a suggestion for how to test that? I knew of the sign bit being 0 check in instcombine of sdiv so I used that for the 0 case. But I don't know enough about what optimizations can benefit from knowing the sign bit is set.
Perhaps you could check that a bitwise-and with `1 << (bitwidth - 1)` folds to a constant? If that doesn't fold despite knowing the sign bit, then that's a separate bug. :)
http://reviews.llvm.org/D21493
More information about the llvm-commits
mailing list