[llvm-bugs] [Bug 44186] New: Incorrect instcombine transform urem -> icmp+zext with vectors
via llvm-bugs
llvm-bugs at lists.llvm.org
Sat Nov 30 07:28:15 PST 2019
https://bugs.llvm.org/show_bug.cgi?id=44186
Bug ID: 44186
Summary: Incorrect instcombine transform urem -> icmp+zext with
vectors
Product: libraries
Version: trunk
Hardware: All
OS: All
Status: NEW
Keywords: miscompilation
Severity: normal
Priority: P
Component: Scalar Optimizations
Assignee: unassignedbugs at nondot.org
Reporter: nunoplopes at sapo.pt
CC: lebedev.ri at gmail.com, llvm-bugs at lists.llvm.org,
regehr at cs.utah.edu, spatel+llvm at rotateright.com
Testcase from Transforms/InstCombine/vector-urem.ll:
define <4 x i32> @test_v4i32_one_undef(<4 x i32> %a0) {
%1 = urem <4 x i32> { 1, 1, 1, undef }, %a0
ret <4 x i32> %1
}
=>
define <4 x i32> @test_v4i32_one_undef(<4 x i32> %a0) {
%1 = icmp ne <4 x i32> %a0, { 1, 1, 1, undef }
%2 = zext <4 x i1> %1 to <4 x i32>
ret <4 x i32> %2
}
Transformation doesn't verify!
ERROR: Value mismatch
Example:
<4 x i32> %a0 = < #x00000010 (16), #x00000001 (1), #x00000400 (1024),
#x00000001 (1) >
Source:
<4 x i32> %1 = < #x00000001 (1), #x00000000 (0), #x00000001 (1), #x00000000 (0)
>
Target:
<4 x i1> %1 = < #x1 (1), #x0 (0), #x1 (1), #x1 (1) >
<4 x i32> %2 = < #x00000001 (1), #x00000000 (0), #x00000001 (1), #x00000001 (1)
>
Source value: < #x00000001 (1), #x00000000 (0), #x00000001 (1), #x00000000 (0)
>
Target value: < #x00000001 (1), #x00000000 (0), #x00000001 (1), #x00000001 (1)
>
Essentially, "x urem 1" is 0 for any 'x'. However, the optimized code can
produce 0 or 1.
I guess the easiest fix is to change undef to 1 in the icmp.
--
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/20191130/7105e713/attachment.html>
More information about the llvm-bugs
mailing list