Skip to content

[InstCombine] samesign flag should be dropped in InstCombinerImpl::foldICmpAndConstConst #112476

Closed
@dtcxzyw

Description

Reproducer:

define i1 @src(i32 %x, i32 %y) {
  %shf = lshr i32 %x, %y
  %or = or i32 %shf, %x
  %and = and i32 %or, 1
  %ret = icmp samesign ne i32 %and, 0
  ret i1 %ret
}

define i1 @tgt(i32 %x, i32 %y) {
  %shf1 = shl nuw i32 1, %y
  %or2 = or i32 %shf1, 1
  %and3 = and i32 %x, %or2
  %ret = icmp samesign ne i32 %and3, 0
  ret i1 %ret
}
Transformation doesn't verify!

ERROR: Target is more poisonous than source

Example:
i32 %x = #x80000000 (2147483648, -2147483648)
i32 %y = #x0000001f (31)

Source:
i32 %shf = #x00000001 (1)
i32 %or = #x80000001 (2147483649, -2147483647)
i32 %and = #x00000001 (1)
i1 %ret = #x1 (1)

Target:
i32 %shf1 = #x80000000 (2147483648, -2147483648)
i32 %or2 = #x80000001 (2147483649, -2147483647)
i32 %and3 = #x80000000 (2147483648, -2147483648)
i1 %ret = poison
Source value: #x1 (1)
Target value: poison

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions