| Issue |
185554
|
| Summary |
Missed Optimization: Failure to fold linear floating-point expressions into a single comparison constant.
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
Leo0506
|
```
define i1 @src(<2 x float> %arg0) {
%v0 = extractelement <2 x float> %arg0, i64 0
%v1 = fmul float %v0, 2.000000e+00
%v2 = extractelement <2 x float> %arg0, i64 1
%v3 = fmul float %v2, 2.000000e+00
%v4 = fadd float %v1, -1.000000e+00
%v5 = fadd float %v3, -1.000000e+00
%v6 = fcmp oeq float %v4, 0.000000e+00
%v7 = fcmp oeq float %v5, 0.000000e+00
%v8 = select i1 %v6, i1 %v7, i1 false
ret i1 %v8
}
define i1 @tgt(<2 x float> %arg0) {
%v0 = extractelement <2 x float> %arg0, i64 0
%v6 = fcmp oeq float %v0, 5.000000e-01
%v2 = extractelement <2 x float> %arg0, i64 1
%v7 = fcmp oeq float %v2, 5.000000e-01
%v8 = select i1 %v6, i1 %v7, i1 false
ret i1 %v8
}
```
Alive2: available in alive2 with timeout limit = 50000:
```
----------------------------------------
define i1 @src(<2 x float> %arg0) {
#0:
%v0 = extractelement <2 x float> %arg0, i64 0
%v1 = fmul float %v0, 2.000000
%v2 = extractelement <2 x float> %arg0, i64 1
%v3 = fmul float %v2, 2.000000
%v4 = fadd float %v1, -1.000000
%v5 = fadd float %v3, -1.000000
%v6 = fcmp oeq float %v4, 0.000000
%v7 = fcmp oeq float %v5, 0.000000
%v8 = select i1 %v6, i1 %v7, i1 0
ret i1 %v8
}
=>
define i1 @tgt(<2 x float> %arg0) {
#0:
%v0 = extractelement <2 x float> %arg0, i64 0
%v6 = fcmp oeq float %v0, 0.500000
%v2 = extractelement <2 x float> %arg0, i64 1
%v7 = fcmp oeq float %v2, 0.500000
%v8 = select i1 %v6, i1 %v7, i1 0
ret i1 %v8
}
Transformation seems to be correct!
```
Godbolt: https://godbolt.org/z/EvhrT8Pqb
Pattern found in: https://github.com/dtcxzyw/llvm-opt-benchmark/blob/main/bench/pbrt-v4/optimized/bxdfs.ll
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs