forked from OSchip/llvm-project
b060ce45ca
Summary: `%ret = add nuw i8 %x, C` From [[ https://llvm.org/docs/LangRef.html#add-instruction | langref ]]: nuw and nsw stand for “No Unsigned Wrap” and “No Signed Wrap”, respectively. If the nuw and/or nsw keywords are present, the result value of the add is a poison value if unsigned and/or signed overflow, respectively, occurs. So if `C` is `-1`, `%x` can only be `0`, and the result is always `-1`. I'm not sure we want to use `KnownBits`/`LVI` here, because there is exactly one possible value (all bits set, `-1`), so some other pass should take care of replacing the known-all-ones with constant `-1`. The `test/Transforms/InstCombine/set-lowbits-mask-canonicalize.ll` change *is* confusing. What happening is, before this: (omitting `nuw` for simplicity) 1. First, InstCombine D47428/rL334127 folds `shl i32 1, %NBits`) to `shl nuw i32 -1, %NBits` 2. Then, InstSimplify D47883/rL334222 folds `shl nuw i32 -1, %NBits` to `-1`, 3. `-1` is inverted to `0`. But now: 1. *This* InstSimplify fold `%ret = add nuw i32 %setbit, -1` -> `-1` happens first, before InstCombine D47428/rL334127 fold could happen. Thus we now end up with the opposite constant, and it is all good: https://rise4fun.com/Alive/OA9 https://rise4fun.com/Alive/sldC Was mentioned in D47428 review. Follow-up for D47883. Reviewers: spatel, craig.topper Reviewed By: spatel Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D47908 llvm-svn: 334298 |
||
---|---|---|
.. | ||
2010-12-20-Boolean.ll | ||
2011-01-14-Thread.ll | ||
2011-02-01-Vector.ll | ||
2011-09-05-InsertExtractValue.ll | ||
2011-10-27-BinOpCrash.ll | ||
2011-11-23-MaskedBitsCrash.ll | ||
2013-04-19-ConstantFoldingCrash.ll | ||
AndOrXor.ll | ||
add-mask.ll | ||
addsub.ll | ||
and-icmps-same-ops.ll | ||
and-or-icmp-zero.ll | ||
assume.ll | ||
bitcast-vector-fold.ll | ||
bitreverse-fold.ll | ||
bitreverse.ll | ||
bswap.ll | ||
call.ll | ||
cast-unsigned-icmp-cmp-0.ll | ||
cast.ll | ||
compare.ll | ||
constantfold-add-nuw-allones-to-allones.ll | ||
constantfold-shl-nuw-C-to-C.ll | ||
dead-code-removal.ll | ||
div.ll | ||
exact-nsw-nuw.ll | ||
extract-element.ll | ||
fast-math.ll | ||
fdiv.ll | ||
floating-point-arithmetic.ll | ||
floating-point-compare.ll | ||
fold-builtin-fma.ll | ||
fold-intrinsics.ll | ||
fp-nan.ll | ||
fp-undef.ll | ||
gep.ll | ||
icmp-bool-constant.ll | ||
icmp-constant.ll | ||
icmp-ranges.ll | ||
implies.ll | ||
insertelement.ll | ||
load-relative-32.ll | ||
load-relative.ll | ||
load.ll | ||
log-exp-intrinsic.ll | ||
logic-of-fcmps.ll | ||
maxmin.ll | ||
mul.ll | ||
negate.ll | ||
noalias-ptr.ll | ||
or-icmps-same-ops.ll | ||
or.ll | ||
past-the-end.ll | ||
phi.ll | ||
pr28725.ll | ||
pr33957.ll | ||
ptr_diff.ll | ||
reassociate.ll | ||
rem.ll | ||
require-dominator.ll | ||
returned.ll | ||
select.ll | ||
shift-128-kb.ll | ||
shift-knownbits.ll | ||
shift.ll | ||
shr-nop.ll | ||
shufflevector.ll | ||
signed-div-rem.ll | ||
simplify-nested-bitcast.ll | ||
undef.ll | ||
vec-cmp.ll | ||
vector_gep.ll | ||
vector_ptr_bitcast.ll |