Skip to content

[InstCombine] nsw flag should be dropped in Negator #112666

Closed
@dtcxzyw

Description

Reproducer: https://alive2.llvm.org/ce/z/ZFF_QK

define i8 @src(i8 %x, i8 %y, i1 %c) {
  %t0 = sub nsw i8 0, %x
  %t1 = select i1 %c, i8 %t0, i8 %x
  %t2 = sub i8 %y, %t1
  ret i8 %t2
}

define i8 @tgt(i8 %x, i8 %y, i1 %c) {
  %t0 = sub nsw i8 0, %x
  %1 = select i1 %c, i8 %x, i8 %t0
  %t2 = add i8 %1, %y
  ret i8 %t2
}
Transformation doesn't verify!

ERROR: Target is more poisonous than source

Example:
i8 %x = #x80 (128, -128)
i8 %y = #x00 (0)
i1 %c = #x0 (0)

Source:
i8 %t0 = poison
i8 %t1 = #x80 (128, -128)
i8 %t2 = #x80 (128, -128)

Target:
i8 %t0 = poison
i8 %#1 = poison
i8 %t2 = poison
Source value: #x80 (128, -128)
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