[all-commits] [llvm/llvm-project] c89d73: [LVI] Infer non-zero from equality icmp (#112838)

Yingwei Zheng via All-commits all-commits at lists.llvm.org
Fri Oct 18 06:19:24 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: c89d731c5dc48e34ec4d081fce7e0c94e212b2f0
      https://github.com/llvm/llvm-project/commit/c89d731c5dc48e34ec4d081fce7e0c94e212b2f0
  Author: Yingwei Zheng <dtcxzyw2333 at gmail.com>
  Date:   2024-10-18 (Fri, 18 Oct 2024)

  Changed paths:
    M llvm/lib/Analysis/LazyValueInfo.cpp
    A llvm/test/Transforms/CorrelatedValuePropagation/umax.ll

  Log Message:
  -----------
  [LVI] Infer non-zero from equality icmp (#112838)

This following pattern is common in loop headers:
```
  %101 = sub nuw i64 %78, %98
  %103 = icmp eq i64 %78, %98
  br i1 %103, label %.thread.i.i, label %.preheader.preheader.i.i

.preheader.preheader.i.i:
  %invariant.umin.i.i = call i64 @llvm.umin.i64(i64 %101, i64 9)
  %umax.i = call i64 @llvm.umax.i64(i64 %invariant.umin.i.i, i64 1)
  br label %.preheader.i.i

.preheader.i.i:
  ...
  %116 = add nuw nsw i64 %.011.i.i, 1
  %exitcond.not.i = icmp eq i64 %116, %umax.i
  br i1 %exitcond.not.i, label %.critedge.i.i, label %.preheader.i.i
```
As `%78` is not equal to `%98` in BB `.preheader.preheader.i.i`, we can
prove `%101` is non-zero. Then we can simplify the loop exit condition.

Addresses regression introduced by
https://github.com/llvm/llvm-project/pull/112742.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list