@@ -335,6 +335,42 @@ define i1 @test_xor_of_bittest_ne_ne(i8 %x, i8 %y) {
335335 ret i1 %xor
336336}
337337
338+ define i1 @test_xor_of_bittest_ne_ne_var_pow2 (i8 %x , i8 %y , i8 %shamt ) {
339+ ; CHECK-LABEL: @test_xor_of_bittest_ne_ne_var_pow2(
340+ ; CHECK-NEXT: [[POW2:%.*]] = shl nuw i8 1, [[SHAMT:%.*]]
341+ ; CHECK-NEXT: [[Y:%.*]] = xor i8 [[X:%.*]], [[Y1:%.*]]
342+ ; CHECK-NEXT: [[MASK2:%.*]] = and i8 [[Y]], [[POW2]]
343+ ; CHECK-NEXT: [[CMP2:%.*]] = icmp ne i8 [[MASK2]], 0
344+ ; CHECK-NEXT: ret i1 [[CMP2]]
345+ ;
346+ %pow2 = shl nuw i8 1 , %shamt
347+ %mask1 = and i8 %x , %pow2
348+ %cmp1 = icmp ne i8 %mask1 , 0
349+ %mask2 = and i8 %y , %pow2
350+ %cmp2 = icmp ne i8 %mask2 , 0
351+ %xor = xor i1 %cmp1 , %cmp2
352+ ret i1 %xor
353+ }
354+
355+ define i1 @test_xor_of_bittest_ne_ne_var_pow2_or_zero (i8 %x , i8 %y , i8 %z ) {
356+ ; CHECK-LABEL: @test_xor_of_bittest_ne_ne_var_pow2_or_zero(
357+ ; CHECK-NEXT: [[NZ:%.*]] = sub i8 0, [[Z:%.*]]
358+ ; CHECK-NEXT: [[TMP1:%.*]] = xor i8 [[X:%.*]], [[Y:%.*]]
359+ ; CHECK-NEXT: [[TMP2:%.*]] = and i8 [[TMP1]], [[NZ]]
360+ ; CHECK-NEXT: [[MASK2:%.*]] = and i8 [[TMP2]], [[Z]]
361+ ; CHECK-NEXT: [[CMP2:%.*]] = icmp ne i8 [[MASK2]], 0
362+ ; CHECK-NEXT: ret i1 [[CMP2]]
363+ ;
364+ %nz = sub i8 0 , %z
365+ %pow2 = and i8 %z , %nz
366+ %mask1 = and i8 %x , %pow2
367+ %cmp1 = icmp ne i8 %mask1 , 0
368+ %mask2 = and i8 %y , %pow2
369+ %cmp2 = icmp ne i8 %mask2 , 0
370+ %xor = xor i1 %cmp1 , %cmp2
371+ ret i1 %xor
372+ }
373+
338374define i1 @test_xor_of_bittest_eq_eq (i8 %x , i8 %y ) {
339375; CHECK-LABEL: @test_xor_of_bittest_eq_eq(
340376; CHECK-NEXT: [[Y:%.*]] = xor i8 [[X:%.*]], [[Y1:%.*]]
0 commit comments