Issue 143529
Summary Missed optimization: propagate not of `trunc nuw ... it1` equalities
Labels new issue
Assignees
Reporter 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 

```ll
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:

```ll
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](https://alive2.llvm.org/ce/z/AbsgX_)

Discussed in  #143273 
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to