LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 43730 - Incorrect 'icmp sle' -> 'icmp slt' w/ vectors
Summary: Incorrect 'icmp sle' -> 'icmp slt' w/ vectors
Status: RESOLVED FIXED
Alias: None
Product: libraries
Classification: Unclassified
Component: Scalar Optimizations (show other bugs)
Version: trunk
Hardware: All All
: P normal
Assignee: Sanjay Patel
URL:
Keywords: miscompilation
: 43731 (view as bug list)
Depends on:
Blocks:
 
Reported: 2019-10-20 04:30 PDT by Nuno Lopes
Modified: 2019-10-29 08:14 PDT (History)
5 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nuno Lopes 2019-10-20 04:30:02 PDT
This transformation exposed in Transforms/InstCombine/icmp-vec.ll is incorrect. The issue is that "INT_MIN <= undef" is not the same as "INT_MIN < undef".

define <2 x i1> @PR27756_2(<2 x i8> %a) {
  %cmp = icmp sle <2 x i8> %a, { undef, 0 }
  ret <2 x i1> %cmp
}
=>
define <2 x i1> @PR27756_2(<2 x i8> %a) {
  %cmp = icmp slt <2 x i8> %a, { undef, 1 }
  ret <2 x i1> %cmp
}
Transformation doesn't verify!
ERROR: Value mismatch

Example:
<2 x i8> %a = < #x80 (128, -128), #x80 (128, -128) >

Source:
<2 x i1> %cmp = < #x1 (1), #x1 (1) >

Target:
<2 x i1> %cmp = < #x0 (0), #x1 (1) >
Source value: < #x1 (1), #x1 (1) >
Target value: < #x0 (0), #x1 (1) >
Comment 1 Sanjay Patel 2019-10-28 09:47:13 PDT
This bug was probably recently introduced via an improvement for icmp canonicalization. I'll propose a fix.
Comment 2 Sanjay Patel 2019-10-28 12:35:37 PDT
https://reviews.llvm.org/D69519
Comment 3 Sanjay Patel 2019-10-29 08:10:57 PDT
Should be fixed by replacing undefs with safe constants:
https://reviews.llvm.org/rGa22282be54b3
Comment 4 Sanjay Patel 2019-10-29 08:14:08 PDT
*** Bug 43731 has been marked as a duplicate of this bug. ***