[llvm] [InstSimplify] Do not simplify a multi-use freeze in `simplifyWithOpReplaced` (PR #91215)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Mon May 6 23:11:46 PDT 2024


dtcxzyw wrote:

Another case with one-use freeze: https://alive2.llvm.org/ce/z/Qyh5h6
```
define i1 @func638(i16 %0, i16 %1) {
  %3 = icmp uge i16 %0, %1
  %4 = sext i1 %3 to i16
  %5 = freeze i16 %4
  %6 = icmp uge i16 %5, %1
  ret i1 %6
}
```
```

----------------------------------------
define i1 @func638(i16 %#0, i16 %#1) {
#2:
  %#3 = icmp uge i16 %#0, %#1
  %#4 = sext i1 %#3 to i16
  %#5 = freeze i16 %#4
  %#6 = icmp uge i16 %#5, %#1
  ret i1 %#6
}
=>
define i1 @func638(i16 %#0, i16 %#1) nofree noundef willreturn memory(none) {
#2:
  %#3 = icmp uge i16 %#0, %#1
  %.fr = freeze i1 %#3
  ret i1 %.fr
}
Transformation doesn't verify!

ERROR: Value mismatch

Example:
i16 %#0 = poison
i16 %#1 = #x0000 (0)

Source:
i1 %#3 = poison
i16 %#4 = poison
i16 %#5 = #x0000 (0)
i1 %#6 = #x1 (1)

Target:
i1 %#3 = poison
i1 %.fr = #x0 (0)
Source value: #x1 (1)
Target value: #x0 (0)

Summary:
  0 correct transformations
  1 incorrect transformations
  0 failed-to-prove transformations
  0 Alive2 errors
```

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


More information about the llvm-commits mailing list