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: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to