Issue 128460
Summary Missed Optimization: simplifying truncated shift-and-mask to direct masking and comparison
Labels new issue
Assignees
Reporter Cancelll
    Example: https://godbolt.org/z/bb68b44rP

Alive2: https://alive2.llvm.org/ce/z/USKkBX

```llvm
define i1 @src(ptr noundef readonly captures(none) %0) {
  %2 = load i64, ptr %0, align 8
  %3 = trunc i64 %2 to i32
  %4 = lshr i32 %3, 8
  %5 = and i32 %4, 255
  %6 = add nsw i32 %5, -1
  %7 = icmp ult i32 %6, 2
  ret i1 %7
}

define i1 @tgt(ptr noundef readonly captures(none) %0) {
  %2 = load i64, ptr %0, align 8
  %5 = and i64 %2, 65280
  %6 = add nsw i64 %5, -256
  %7 = icmp ult i64 %6, 512
  ret i1 %7
}
```
I found this pattern in function ossl_quic_free in openssl/ssl/quic/quic_impl.c
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to