[PATCH] D23468: [ValueTracking] Sign bit of shl cannot be both known one and known zero. Fix PR28926

Li Huang via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 12 14:53:09 PDT 2016


lihuang created this revision.
lihuang added reviewers: majnemer, sanjoy.
lihuang added a subscriber: llvm-commits.

[ValueTracking] Sign bit of shl cannot be both known one and known zero. Fix PR28926 

This is to fix PR28296 caused by r278172 (D23296). When inferring the sign bit of a SHL from nsw flag, should update both KnownZero and KnownOne's sign bit. If the result of SHL is known to be non-negative, should set the sign bit of KnownZero to 1 and KnownOne to 0, vice versa. This cannot be implemented in KZF and KOF, because KZF only modifies knownZero and KOF only modifies knownOne.

Also made a little change to computeKnownBitsFromShiftOperator: extract the computeKnownBits(...) for operand 0 to its callsite, so that the "infer sign bit from SHL with nsw" logic can be implemented only at the SHL case. 

https://reviews.llvm.org/D23468

Files:
  lib/Analysis/ValueTracking.cpp
  test/Analysis/ValueTracking/known-signbit-shift.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D23468.67911.patch
Type: text/x-patch
Size: 5933 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160812/e2a5b816/attachment.bin>


More information about the llvm-commits mailing list