[LLVMbugs] [Bug 21242] New: InstCombine: mul -> shl shouldn't preserve NSW
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Fri Oct 10 06:14:01 PDT 2014
http://llvm.org/bugs/show_bug.cgi?id=21242
Bug ID: 21242
Summary: InstCombine: mul -> shl shouldn't preserve NSW
Product: libraries
Version: trunk
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P
Component: Scalar Optimizations
Assignee: unassignedbugs at nondot.org
Reporter: nunoplopes at sapo.pt
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
The transformation in InstCombineMulDivRem.cpp, lines 156-187, shouldn't
preserve NSW.
Here's why:
Pre: isPowerOf2(C1)
%r = mul nsw %x, C1
=>
%r = shl nsw %x, log2(C1)
Done: 1
ERROR: Domain of poisoness of Target is smaller than Source's for i2 %r
Example:
%x i2 = 1 (0x1)
C1 i2 = 2 (0x2)
Source value: 2 (0x2)
Target value: poison
The multiplication doesn't overflow (1*-2 = -2), but the shift does (goes from
positive 1 to negative -2).
A fix is to propagate only NUW, and discard NSW.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20141010/47bf9df1/attachment.html>
More information about the llvm-bugs
mailing list