@@ -71,3 +71,37 @@ for.end:
71
71
%tmp1 = phi i32 [ %r.next , %for.body ]
72
72
ret i32 %tmp1
73
73
}
74
+
75
+ define i32 @pr51794_signed_negative (i16 %iv.start , i32 %xor.start ) {
76
+ ; CHECK-LABEL: define {{.*}} @pr51794_signed_negative
77
+ ; CHECK: [[XOR_START:%.+]] = insertelement <4 x i32> zeroinitializer, i32 %xor.start, i32 0
78
+ ; CHECK-LABEL: vector.body:
79
+ ; CHECK: [[XOR_RED:%.+]] = phi <4 x i32> [ [[XOR_START]], %vector.ph ], [ [[XOR_SEXT:%.+]], %vector.body ]
80
+ ; CHECK: [[AND:%.+]] = and <4 x i32> [[XOR_RED]], <i32 1, i32 1, i32 1, i32 1>
81
+ ; CHECK-NEXT: [[XOR:%.+]] = xor <4 x i32> [[AND]], <i32 -1, i32 -1, i32 -1, i32 -1>
82
+ ; CHECK: [[XOR_TRUNC:%.+]] = trunc <4 x i32> [[XOR]] to <4 x i1>
83
+ ; CHECK-NEXT: [[XOR_SEXT]] = sext <4 x i1> [[XOR_TRUNC]] to <4 x i32>
84
+ ;
85
+ ; CHECK-LABEL: middle.block:
86
+ ; CHECK-NEXT: [[RES_TRUNC:%.+]] = trunc <4 x i32> [[XOR_SEXT]] to <4 x i1>
87
+ ; CHECK-NEXT: [[RES_RED:%.+]] = call i1 @llvm.vector.reduce.xor.v4i1(<4 x i1> [[RES_TRUNC]])
88
+ ; CHECK-NEXT: sext i1 [[RES_RED]] to i32
89
+ ;
90
+ entry:
91
+ br label %loop
92
+
93
+ loop:
94
+ %xor.red = phi i32 [ %xor.start , %entry ], [ %xor , %loop ]
95
+ %iv = phi i16 [ %iv.start , %entry ], [ %iv.next , %loop ]
96
+ %iv.next = add i16 %iv , -1
97
+ %and = and i32 %xor.red , 1
98
+ %xor = xor i32 %and , -1
99
+ %tobool.not = icmp eq i16 %iv.next , 0
100
+ br i1 %tobool.not , label %exit , label %loop
101
+
102
+ exit:
103
+ %xor.lcssa = phi i32 [ %xor , %loop ]
104
+ ret i32 %xor.lcssa
105
+ }
106
+
107
+
0 commit comments