Skip to content

Wrong select folding for undef conditions by InstCombine #98435

Closed
@bongjunj

Description

@bongjunj

if (Value *S = simplifyWithOpReplaced(FalseVal, CondVal,
ConstantInt::getFalse(CondType), SQ,
/* AllowRefinement */ true))
return replaceOperand(SI, 2, S);

Alive2 report: https://alive2.llvm.org/ce/z/Qtu72J

----------------------------------------
define <2 x i1> @fun0(<2 x i1> %val0, <2 x i1> %val1) {
#0:
  %val2 = select <2 x i1> %val0, <2 x i1> %val0, <2 x i1> %val0
  %val3 = select <2 x i1> { undef, 1 }, <2 x i1> { 1, 1 }, <2 x i1> %val2
  ret <2 x i1> %val3
}
=>
define <2 x i1> @fun0(<2 x i1> %val0, <2 x i1> %val1) {
#0:
  ret <2 x i1> { poison, 1 }
}
Transformation doesn't verify!

ERROR: Target is more poisonous than source

Example:
<2 x i1> %val0 = < #x0 (0), #x0 (0) >
<2 x i1> %val1 = < #x0 (0), #x0 (0) >

Source:
<2 x i1> %val2 = < #x0 (0), #x0 (0) >
<2 x i1> %val3 = < #x0 (0)	[based on undef value], #x1 (1) >

Target:
Source value: < #x0 (0), #x1 (1) >
Target value: < poison, #x1 (1) >

Summary:
  0 correct transformations
  1 incorrect transformations
  0 failed-to-prove transformations
  0 Alive2 errors

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions