@@ -104,6 +104,20 @@ define i1 @logical_or_implies(i32 %x) {
104104 ret i1 %res
105105}
106106
107+ ; Safe to convert to or due to poison implication.
108+ define <vscale x 2 x i1 > @logical_or_implies_scalablevec (<vscale x 2 x i32 > %x ) {
109+ ; CHECK-LABEL: @logical_or_implies_scalablevec(
110+ ; CHECK-NEXT: [[C1:%.*]] = icmp eq <vscale x 2 x i32> [[X:%.*]], zeroinitializer
111+ ; CHECK-NEXT: [[C2:%.*]] = icmp eq <vscale x 2 x i32> [[X]], splat (i32 42)
112+ ; CHECK-NEXT: [[RES:%.*]] = or <vscale x 2 x i1> [[C1]], [[C2]]
113+ ; CHECK-NEXT: ret <vscale x 2 x i1> [[RES]]
114+ ;
115+ %c1 = icmp eq <vscale x 2 x i32 > %x , zeroinitializer
116+ %c2 = icmp eq <vscale x 2 x i32 > %x , splat (i32 42 )
117+ %res = select <vscale x 2 x i1 > %c1 , <vscale x 2 x i1 > splat (i1 true ), <vscale x 2 x i1 > %c2
118+ ret <vscale x 2 x i1 > %res
119+ }
120+
107121; Will fold after conversion to or.
108122define i1 @logical_or_implies_folds (i32 %x ) {
109123; CHECK-LABEL: @logical_or_implies_folds(
@@ -129,6 +143,20 @@ define i1 @logical_and_implies(i32 %x) {
129143 ret i1 %res
130144}
131145
146+ ; Safe to convert to and due to poison implication.
147+ define <vscale x 2 x i1 > @logical_and_implies_scalablevec (<vscale x 2 x i32 > %x ) {
148+ ; CHECK-LABEL: @logical_and_implies_scalablevec(
149+ ; CHECK-NEXT: [[C1:%.*]] = icmp ne <vscale x 2 x i32> [[X:%.*]], zeroinitializer
150+ ; CHECK-NEXT: [[C2:%.*]] = icmp ne <vscale x 2 x i32> [[X]], splat (i32 42)
151+ ; CHECK-NEXT: [[RES:%.*]] = and <vscale x 2 x i1> [[C1]], [[C2]]
152+ ; CHECK-NEXT: ret <vscale x 2 x i1> [[RES]]
153+ ;
154+ %c1 = icmp ne <vscale x 2 x i32 > %x , zeroinitializer
155+ %c2 = icmp ne <vscale x 2 x i32 > %x , splat (i32 42 )
156+ %res = select <vscale x 2 x i1 > %c1 , <vscale x 2 x i1 > %c2 , <vscale x 2 x i1 > zeroinitializer
157+ ret <vscale x 2 x i1 > %res
158+ }
159+
132160; Will fold after conversion to and.
133161define i1 @logical_and_implies_folds (i32 %x ) {
134162; CHECK-LABEL: @logical_and_implies_folds(
0 commit comments