Skip to content

[InstCombine] noundef attribute should be dropped after setting is_zero_poison to true #112068

Closed
@dtcxzyw

Description

@dtcxzyw

Reproducer: https://alive2.llvm.org/ce/z/7-TgAf

define i32 @src(i32 %x, i32 %y) {
entry:
  %cttz = call noundef i32 @llvm.cttz.i32(i32 %y, i1 false)
  %res = lshr i32 %x, %cttz
  ret i32 %res
}

define i32 @tgt(i32 %x, i32 %y) {
entry:
  %cttz = call noundef i32 @llvm.cttz.i32(i32 %y, i1 true)
  %res = lshr i32 %x, %cttz
  ret i32 %res
}

define i32 @src2(i32 %x) {
  %ct = call noundef i32 @llvm.ctlz.i32(i32 %x, i1 false)
  %cmp = icmp ne i32 %x, 0
  %res = select i1 %cmp, i32 %ct, i32 123
  ret i32 %res
}

define i32 @tgt2(i32 %x) {
  %ct = call noundef i32 @llvm.ctlz.i32(i32 %x, i1 true)
  %cmp = icmp ne i32 %x, 0
  %res = select i1 %cmp, i32 %ct, i32 123
  ret i32 %res
}

noundef attribute should be dropped. Otherwise we will convert a poison value to immediate UB.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions