HomePhabricator

[docs] Make it clear shifts yield poison when shift amount >= bitwidth

Description

[docs] Make it clear shifts yield poison when shift amount >= bitwidth

Some InstCombine optimizations already rely on the result being poison
rather than undef.

For example, the following rewrite is wrong if undef is used:
; (1 << Y) * X -> X << Y
%Op0 = shl 1, %Y
%r = mul %Op0, %Op1

=>

%r = shl %Op1, %Y

ERROR: Mismatch in values for i4 %r

Example:
i4 %Y = 0x8 (8, -8)
i4 %Op0 = 0x0 (0)
i4 %Op1 = 0x0 (0)
source: 0x0 (0)
target: 0x1 (1)

The optimization is correct if poison is returned instead:
http://rise4fun.com/Alive/ygX

Differential Revision: https://reviews.llvm.org/D33654

Details

Committed
nlopesJun 6 2017, 1:28 AM
Differential Revision
D33654: [docs] Make it clear shifts yield poison when shift amount >= bitwidth
Parents
rL304779:
Branches
Unknown
Tags
Unknown