[llvm] [ConstantRange] Add support for `shlWithNoWrap` (PR #100594)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 25 10:04:05 PDT 2024


dtcxzyw wrote:

> > However, this patch cannot fix the original issue.
> 
> How come? Due to the suboptimal ranges found?

```
define i1 @src10(i32 %0, i32 %1) {
entry:
  %2 = add nsw i32 %0, %1
  %3 = shl nuw nsw i32 768, %2
  %use = add nuw i32 %3, 1846
  %4 = icmp sgt i32 %use, 0
  ret i1 %4
}

define i1 @tgt10(i32 %0, i32 %1) {
entry:
  ret i1 true
}
```

Yeah, LLVM now produces `[768, 2147483647]` for `%3 = shl nuw nsw i32 768, %2`. But `[768, 768 << (31 - ctlz(768))]` is obviously better.



https://github.com/llvm/llvm-project/pull/100594


More information about the llvm-commits mailing list