Skip to content

Instcombine: incorrect transformation 'x > (x & undef)' -> 'x > undef' #43728

@nunoplopes

Description

@nunoplopes
Bugzilla Link 44383
Resolution FIXED
Resolved on Oct 23, 2020 18:33
Version trunk
OS All
Blocks #47292
CC @LebedevRI,@RKSimon,@regehr,@rotateright
Fixed by commit(s) rG164058274364

Extended Description

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'.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions