Skip to content

InstCombine incorrectly folds select of vector #49176

@aqjune

Description

@aqjune
Bugzilla Link 49832
Resolution FIXED
Resolved on May 29, 2021 08:41
Version trunk
OS All
Blocks #48246 #48661
CC @RKSimon,@nikic,@smeenai,@rotateright,@tstellar
Fixed by commit(s) c0b0da4 c590a98 78e5cf6 e2a0f51 c89d500 4a12f51 266c82f 8e2ff38

Extended Description

$ cat src.ll define void @&#8203;src(<2 x i32> %input) { %cond = icmp eq <2 x i32> %input, zeroinitializer %.14 = extractelement <2 x i32> %input, i32 1 %.15 = insertelement <2 x i32> poison, i32 %.14, i32 0 %.16 = extractelement <2 x i32> %input, i32 0 %.17 = insertelement <2 x i32> %.15, i32 %.16, i32 1 %.18 = select <2 x i1> %cond, <2 x i32> %.17, <2 x i32> %input %x = extractelement <2 x i32> %.18, i32 0 %y = extractelement <2 x i32> %.18, i32 1 call void @&#8203;f(i32 %x, i32 %y) ret void } declare void @&#8203;f(i32, i32) $ opt -instcombine -S -o - src.ll define void @&#8203;src(<2 x i32> %input) { %x = extractelement <2 x i32> %input, i32 0 %y = extractelement <2 x i32> %input, i32 1 call void @&#8203;f(i32 %x, i32 %y) ret void } declare void @&#8203;f(i32, i32) 

This is incorrect: https://alive2.llvm.org/ce/z/8X-4kR
If input is <0, 2>, (%x, %y) is (2, 2) in src, but it becomes (0, 2) in tgt.

Metadata

Metadata

Assignees

Labels

bugzillaIssues migrated from bugzilla

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions