Issue 238902
Summary [SLP] missing optimization for `trunc to i1` and `icmp eq` conditions
Labels new issue
Assignees
Reporter andjo403
    when `icmp eq (and x, 1), 0` is folded to `trunc x to i1` the select arms is swapped,
resulting in the the fix in https://github.com/llvm/llvm-project/pull/233124 do not match

```
define <2 x float> @src(i32 %flags, float %a, float %b) {
  %c0 = trunc i32 %flags to i1
  %s0 = select i1 %c0, float 0.0, float %a
  %m1 = and i32 %flags, 2
  %c1 = icmp eq i32 %m1, 0
  %s1 = select i1 %c1, float %b, float 0.0
 %v0 = insertelement <2 x float> poison, float %s0, i64 0
  %v1 = insertelement <2 x float> %v0, float %s1, i64 1
  ret <2 x float> %v1
}

define <2 x float> @tgt(i32 %flags, float %a, float %b) {
  %1 = insertelement <2 x i32> poison, i32 %flags, i64 0
  %2 = shufflevector <2 x i32> %1, <2 x i32> poison, <2 x i32> zeroinitializer
  %3 = and <2 x i32> %2, <i32 1, i32 2>
  %4 = icmp eq <2 x i32> %3, zeroinitializer
  %5 = insertelement <2 x float> poison, float %a, i64 0
  %6 = insertelement <2 x float> %5, float %b, i64 1
  %7 = select <2 x i1> %4, <2 x float> %6, <2 x float> zeroinitializer
  ret <2 x float> %7
}
```

https://alive2.llvm.org/ce/z/3vP_xy
regressions seen in https://github.com/dtcxzyw/llvm-opt-benchmark-nightly/pull/1794/changes#r4471130452
cc @alexey-bataev 
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to