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 44383 - Instcombine: incorrect transformation 'x > (x & undef)' -> 'x > undef'
Summary: Instcombine: incorrect transformation 'x > (x & undef)' -> 'x > undef'
Status: RESOLVED FIXED
Alias: None
Product: libraries
Classification: Unclassified
Component: Scalar Optimizations (show other bugs)
Version: trunk
Hardware: All All
: P normal
Assignee: Unassigned LLVM Bugs
URL:
Keywords: miscompilation
Depends on:
Blocks: 47948
  Show dependency tree
 
Reported: 2019-12-26 11:39 PST by Nuno Lopes
Modified: 2020-10-23 18:33 PDT (History)
5 users (show)

See Also:
Fixed By Commit(s): rG164058274364


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nuno Lopes 2019-12-26 11:39:34 PST
The following transformation in Transforms/InstCombine/canonicalize-constant-low-bit-mask-and-icmp-sgt-to-icmp-sgt.ll is incorrect:

define <3 x i1> @p3_vec_splat_undef() {
  %x = call <3 x i8> @gen3x8()
  %tmp0 = and <3 x i8> %x, { 3, undef, 3 }
  %ret = icmp sgt <3 x i8> %x, %tmp0
  ret <3 x i1> %ret
}
=>
define <3 x i1> @p3_vec_splat_undef() {

  %x = call <3 x i8> @gen3x8()
  %1 = icmp sgt <3 x i8> %x, { 3, undef, 3 }
  ret <3 x i1> %1
}

Transformation doesn't verify!
ERROR: Value mismatch

Example:

Source:
<3 x i8> %x = < poison, #x00 (0), poison >
<3 x i8> %tmp0 = < poison, #x00 (0), poison >
<3 x i1> %ret = < poison, #x0 (0), poison >

Target:
<3 x i8> %x = < poison, #x00 (0), poison >
<3 x i1> %1 = < poison, #x1 (1), poison >
Source value: < poison, #x0 (0), poison >
Target value: < poison, #x1 (1), poison >


The transformation does 'x > (x & undef)' -> 'x > undef'.
Take x=0, undef=-1, and we get '0 > 0' -> '0 > -1'.
Comment 1 Sanjay Patel 2020-01-02 12:59:22 PST
https://reviews.llvm.org/D72101
Comment 2 Simon Pilgrim 2020-02-08 09:36:27 PST
(In reply to Sanjay Patel from comment #1)
> https://reviews.llvm.org/D72101

@nlopes @spatel This landed at rG164058274364 - resolve this?
Comment 3 Sanjay Patel 2020-02-08 09:39:05 PST
Forgot to mark this bug as fixed with:
https://reviews.llvm.org/rG164058274364670c8b59055b4689ae7e1720268e