[PATCH] D124327: [SCCP] Add initial support for propagation through freeze.

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 25 08:10:17 PDT 2022


nikic added inline comments.


================
Comment at: llvm/test/Transforms/SCCP/freeze.ll:48
+; CHECK-NEXT:    call void @use(i1 true)
+; CHECK-NEXT:    call void @use(i1 false)
 ; CHECK-NEXT:    [[C_1:%.*]] = icmp eq i32 [[AND_FR]], [[Y:%.*]]
----------------
Let's assume `%x` is poison here, then `%and` is poison and `%and.fr` can take any value, while you assume that it must be in `[0,3]`.

Here's an example of how this goes wrong across multiple passes:
```
declare void @use(i64) 
 
define internal i1 @test(i64 %a) {
  %b = or i64 %a, 2 
  %x = freeze i64 %b
  call void @use(i64 %x) 
  %c = icmp eq i64 %x, 0 
  ret i1 %c
} 
 
define i1 @test2() {
  %c = call i1 @test(i64 poison)
  ret i1 %c
}

; opt -S -sccp -inline -instcombine

define i1 @test2() {
  call void @use(i64 0)
  ret i1 false
}
```

As you can see, we both claim that `%x != 0` and pass `%x == 0` to `@use()`. This example uses `-sccp` to make sure SCCP doesn't have a global view.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D124327/new/

https://reviews.llvm.org/D124327



More information about the llvm-commits mailing list