[all-commits] [llvm/llvm-project] b0f787: [SCCP] Propagate equality of a not-constant

luxufan via All-commits all-commits at lists.llvm.org
Mon Dec 5 03:54:38 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: b0f78769178ebb5e0691aca5143fead7f79ee55c
      https://github.com/llvm/llvm-project/commit/b0f78769178ebb5e0691aca5143fead7f79ee55c
  Author: luxufan <luxufan at iscas.ac.cn>
  Date:   2022-12-05 (Mon, 05 Dec 2022)

  Changed paths:
    M llvm/lib/Transforms/Utils/SCCPSolver.cpp
    M llvm/test/Transforms/SCCP/conditions-ranges.ll

  Log Message:
  -----------
  [SCCP] Propagate equality of a not-constant

The equality state of a not-constant can be used to do constant
propagation. For example,
```
define i32 @equal_not_constant(ptr noundef %p, ptr noundef %q) {
entry:
  %cmp = icmp ne ptr %p, null
  br i1 %cmp, label %if.then, label %if.end

if.then:                                          ; preds = %entry
  %cmp.then = icmp eq ptr %p, %q
  br i1 %cmp.then, label %if.then1, label %if.end

if.then1:                                         ; preds = %if.then
  %cmp.then1 = icmp ne ptr %q, null
  call void @use(i1 %cmp.then1)
  br label %if.end

if.end:
  ret i32 0
}

```
In this case, we can fold `%cmp.then1` as `true`.

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D139289




More information about the All-commits mailing list