[PATCH] D58329: [ValueTracking] Known bits support for unsigned saturating add/sub
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Feb 17 10:37:16 PST 2019
nikic created this revision.
nikic added reviewers: spatel, RKSimon.
Herald added subscribers: llvm-commits, jdoerfert.
Herald added a project: LLVM.
This adds known bits support for the unsigned saturating add/sub intrinsics. The procedure is basically:
1. Compute known bits for a normal add/sub with one extra bit to capture the carry-out.
2. If known overflow, use the saturation value (all ones or zero).
3. If known no overflow, use the add/sub result.
4. If unknown overflow: For additions we can preserve leading ones, because either there is no carry into the ones and they stay, or there is one, the result overflows and all ones is used (which also has leading ones). Additionally we preserve ones in the add result, as we're selecting between the add result and all ones. For subtractions the situation is the same but with zeros instead of ones.
I'm only handling the unsigned case here as it is simpler. It's likely not worthwhile having known bits for the signed cases at all, as we just can't get a lot of information there.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 6349 bytes
Desc: not available
More information about the llvm-commits