Skip to content
Commit b0f78769 authored by luxufan's avatar luxufan
Browse files

[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
parent fc85ccd7
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment