@@ -740,3 +740,71 @@ end:
740740 call void @use (i1 %t.3 )
741741 ret void
742742}
743+
744+ define void @test_decompose_bitwise_and_negative (i4 %x , i4 %y ) {
745+ ; CHECK-LABEL: @test_decompose_bitwise_and_negative(
746+ ; CHECK-NEXT: entry:
747+ ; CHECK-NEXT: [[AND_1:%.*]] = and i4 [[Y:%.*]], [[X:%.*]]
748+ ; CHECK-NEXT: [[C_1:%.*]] = icmp slt i4 [[AND_1]], 0
749+ ; CHECK-NEXT: br i1 [[C_1]], label [[THEN:%.*]], label [[END:%.*]]
750+ ; CHECK: then:
751+ ; CHECK-NEXT: ret void
752+ ; CHECK: end:
753+ ; CHECK-NEXT: [[C_2:%.*]] = icmp sgt i4 [[X]], 0
754+ ; CHECK-NEXT: [[C_3:%.*]] = icmp sgt i4 [[Y]], 0
755+ ; CHECK-NEXT: call void @use(i1 [[C_2]])
756+ ; CHECK-NEXT: call void @use(i1 [[C_3]])
757+ ; CHECK-NEXT: ret void
758+ ;
759+ entry:
760+ %and.1 = and i4 %y , %x
761+ %c.1 = icmp slt i4 %and.1 , 0
762+ br i1 %c.1 , label %then , label %end
763+
764+ then:
765+ ; fact: %and.1 < 0
766+ ret void
767+
768+ end:
769+ ; fact: %and.1 >= 0
770+ ; %c.2, %c.3 should only be replaced in the bitwise OR case
771+ %c.2 = icmp sgt i4 %x , 0
772+ %c.3 = icmp sgt i4 %y , 0
773+ call void @use (i1 %c.2 )
774+ call void @use (i1 %c.3 )
775+ ret void
776+ }
777+
778+ define void @test_decompose_bitwise_and_negative_2 (i4 %x , i4 %y ) {
779+ ; CHECK-LABEL: @test_decompose_bitwise_and_negative_2(
780+ ; CHECK-NEXT: entry:
781+ ; CHECK-NEXT: [[AND_1:%.*]] = and i4 [[X:%.*]], [[Y:%.*]]
782+ ; CHECK-NEXT: [[C_1:%.*]] = icmp sgt i4 [[AND_1]], -1
783+ ; CHECK-NEXT: br i1 [[C_1]], label [[THEN:%.*]], label [[END:%.*]]
784+ ; CHECK: then:
785+ ; CHECK-NEXT: [[C_2:%.*]] = icmp sgt i4 [[X]], 0
786+ ; CHECK-NEXT: [[C_3:%.*]] = icmp sgt i4 [[Y]], 0
787+ ; CHECK-NEXT: call void @use(i1 [[C_2]])
788+ ; CHECK-NEXT: call void @use(i1 [[C_3]])
789+ ; CHECK-NEXT: ret void
790+ ; CHECK: end:
791+ ; CHECK-NEXT: ret void
792+ ;
793+ entry:
794+ %and.1 = and i4 %x , %y
795+ %c.1 = icmp sgt i4 %and.1 , -1
796+ br i1 %c.1 , label %then , label %end
797+
798+ then:
799+ ; fact: %and.1 > -1
800+ ; %c.1, %c.2 should only be replaced in the bitwise OR case
801+ %c.2 = icmp sgt i4 %x , 0
802+ %c.3 = icmp sgt i4 %y , 0
803+ call void @use (i1 %c.2 )
804+ call void @use (i1 %c.3 )
805+ ret void
806+
807+ end:
808+ ; fact: %and.1 <= -1
809+ ret void
810+ }
0 commit comments