Skip to content

Missed optimization: propagate not of trunc nuw ... it1 equalities #143529

Open
@yashnator

Description

@yashnator

Not of trunc nuw iN ... to i1 equalities can be propagated.

For example, store i8 %v, ptr %p, align 8 -> store i8 0, ptr %p, align 8 in

define i8 @src(ptr %p, i8 %v, i1 %cond) {
  %trunc = trunc nuw i8 %v to i1
  %not = xor i1 %trunc, true
  %and = and i1 %not, %cond
  br i1 %and, label %3, label %common.ret

common.ret:
  ret i8 0

3:
  store i8 %v, ptr %p, align 8
  br label %common.ret
}

should be optimized to:

define i8 @src(ptr %p, i8 %v, i1 %cond) {
  %trunc = trunc nuw i8 %v to i1
  %not = xor i1 %trunc, true
  %and = and i1 %not, %cond
  br i1 %and, label %3, label %common.ret

common.ret:
  ret i8 0

3:
  store i8 0, ptr %p, align 8
  br label %common.ret
}

Alive2 and opt

Discussed in #143273

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions