Skip to content

[KnownBits] (Trunc X) != 1 implies X != 1 #118104

Open
@dtcxzyw

Description

@dtcxzyw

Alive2: https://alive2.llvm.org/ce/z/3yxP4T

define i1 @src1(i64 %x) {
entry:
  %trunc = trunc i64 %x to i32
  %cond = icmp ne i32 %trunc, 1
  call void @llvm.assume(i1 %cond)
  %cmp = icmp eq i64 %x, 1
  ret i1 %cmp
}

define i1 @tgt1(i64 %x) {
entry:
  ret i1 false
}

define i1 @src2(i64 %x) {
entry:
  %trunc = trunc i64 %x to i1
  %not = xor i1 %trunc, true
  call void @llvm.assume(i1 %not)
  %cmp = icmp eq i64 %x, 1
  ret i1 %cmp
}

define i1 @tgt2(i64 %x) {
entry:
  ret i1 false
}

The second pattern is common in Rust applications. See also dtcxzyw/llvm-tools#36.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions