http://llvm.org/bugs/show_bug.cgi?id=21245
Bug ID: 21245
Summary: InstCombine: (X << C1) / C2 -> X / (C2 >> C1) isn't
always possible
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
In InstCombiner::commonIDivTransforms(), we have the following transformation:
// (X << C1) / C2 -> X / (C2 >> C1) if C2 is a multiple of C1.
However, this is not correct if C1 == width(C1) - 1.
Optimization: 775
Pre: C2 % (1<<C1) == 0
%s = shl nsw i4 %X, C1
%r = sdiv %s, C2
=>
%r = sdiv %X, (C2 / (1 << C1))
ERROR: Mismatch in values of i4 %r
Example:
%X i4 = 15 (0xf)
C1 i4 = 3 (0x3)
C2 i4 = 8 (0x8)
%s i4 = 8 (0x8)
Source value: 1 (0x1)
Target value: 15 (0xf)
This version is correct though:
Name: 775
Pre: C2 % (1<<C1) == 0 && C1 != width(C1)-1
%s = shl nsw %X, C1
%r = sdiv %s, C2
=>
%r = sdiv %X, C2/(1<<C1)
--
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