@@ -659,3 +659,126 @@ for.inc:
659659for.end:
660660 ret void
661661}
662+
663+ define void @sdiv_with_uniform_ops (i16 %0 , i1 %c , ptr %dst ) {
664+ ; UNROLL-LABEL: @sdiv_with_uniform_ops(
665+ ; UNROLL-NEXT: entry:
666+ ; UNROLL-NEXT: br label [[VECTOR_BODY:%.*]]
667+ ; UNROLL: vector.body:
668+ ; UNROLL-NEXT: [[INDEX:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[INDEX_NEXT:%.*]], [[PRED_STORE_CONTINUE2:%.*]] ]
669+ ; UNROLL-NEXT: br i1 [[C:%.*]], label [[PRED_STORE_IF:%.*]], label [[PRED_STORE_CONTINUE2]]
670+ ; UNROLL: pred.store.if:
671+ ; UNROLL-NEXT: [[TMP1:%.*]] = sdiv i16 10, [[TMP0:%.*]]
672+ ; UNROLL-NEXT: store i16 [[TMP1]], ptr [[DST:%.*]], align 1
673+ ; UNROLL-NEXT: [[TMP2:%.*]] = sdiv i16 10, [[TMP0]]
674+ ; UNROLL-NEXT: store i16 [[TMP2]], ptr [[DST]], align 1
675+ ; UNROLL-NEXT: br label [[PRED_STORE_CONTINUE2]]
676+ ; UNROLL: pred.store.continue2:
677+ ; UNROLL-NEXT: [[INDEX_NEXT]] = add nuw i32 [[INDEX]], 2
678+ ; UNROLL-NEXT: [[TMP3:%.*]] = icmp eq i32 [[INDEX_NEXT]], 98
679+ ; UNROLL-NEXT: br i1 [[TMP3]], label [[LOOP_HEADER:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP6:![0-9]+]]
680+ ; UNROLL: loop.header:
681+ ; UNROLL-NEXT: [[IV:%.*]] = phi i16 [ [[INC:%.*]], [[LOOP_LATCH:%.*]] ], [ 99, [[PRED_STORE_CONTINUE2]] ]
682+ ; UNROLL-NEXT: br i1 [[C]], label [[THEN:%.*]], label [[LOOP_LATCH]]
683+ ; UNROLL: then:
684+ ; UNROLL-NEXT: [[DIV:%.*]] = sdiv i16 10, [[TMP0]]
685+ ; UNROLL-NEXT: store i16 [[DIV]], ptr [[DST]], align 1
686+ ; UNROLL-NEXT: br label [[LOOP_LATCH]]
687+ ; UNROLL: loop.latch:
688+ ; UNROLL-NEXT: [[INC]] = add i16 [[IV]], 1
689+ ; UNROLL-NEXT: [[EC:%.*]] = icmp eq i16 [[INC]], 100
690+ ; UNROLL-NEXT: br i1 [[EC]], label [[EXIT:%.*]], label [[LOOP_HEADER]], !llvm.loop [[LOOP7:![0-9]+]]
691+ ; UNROLL: exit:
692+ ; UNROLL-NEXT: ret void
693+ ;
694+ ; UNROLL-NOSIMPLIFY-LABEL: @sdiv_with_uniform_ops(
695+ ; UNROLL-NOSIMPLIFY-NEXT: entry:
696+ ; UNROLL-NOSIMPLIFY-NEXT: br i1 false, label [[SCALAR_PH:%.*]], label [[VECTOR_PH:%.*]]
697+ ; UNROLL-NOSIMPLIFY: vector.ph:
698+ ; UNROLL-NOSIMPLIFY-NEXT: br label [[VECTOR_BODY:%.*]]
699+ ; UNROLL-NOSIMPLIFY: vector.body:
700+ ; UNROLL-NOSIMPLIFY-NEXT: [[INDEX:%.*]] = phi i32 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[PRED_STORE_CONTINUE2:%.*]] ]
701+ ; UNROLL-NOSIMPLIFY-NEXT: br i1 [[C:%.*]], label [[PRED_STORE_IF:%.*]], label [[PRED_STORE_CONTINUE:%.*]]
702+ ; UNROLL-NOSIMPLIFY: pred.store.if:
703+ ; UNROLL-NOSIMPLIFY-NEXT: [[TMP1:%.*]] = sdiv i16 10, [[TMP0:%.*]]
704+ ; UNROLL-NOSIMPLIFY-NEXT: store i16 [[TMP1]], ptr [[DST:%.*]], align 1
705+ ; UNROLL-NOSIMPLIFY-NEXT: br label [[PRED_STORE_CONTINUE]]
706+ ; UNROLL-NOSIMPLIFY: pred.store.continue:
707+ ; UNROLL-NOSIMPLIFY-NEXT: br i1 [[C]], label [[PRED_STORE_IF1:%.*]], label [[PRED_STORE_CONTINUE2]]
708+ ; UNROLL-NOSIMPLIFY: pred.store.if1:
709+ ; UNROLL-NOSIMPLIFY-NEXT: [[TMP2:%.*]] = sdiv i16 10, [[TMP0]]
710+ ; UNROLL-NOSIMPLIFY-NEXT: store i16 [[TMP2]], ptr [[DST]], align 1
711+ ; UNROLL-NOSIMPLIFY-NEXT: br label [[PRED_STORE_CONTINUE2]]
712+ ; UNROLL-NOSIMPLIFY: pred.store.continue2:
713+ ; UNROLL-NOSIMPLIFY-NEXT: [[INDEX_NEXT]] = add nuw i32 [[INDEX]], 2
714+ ; UNROLL-NOSIMPLIFY-NEXT: [[TMP3:%.*]] = icmp eq i32 [[INDEX_NEXT]], 98
715+ ; UNROLL-NOSIMPLIFY-NEXT: br i1 [[TMP3]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP10:![0-9]+]]
716+ ; UNROLL-NOSIMPLIFY: middle.block:
717+ ; UNROLL-NOSIMPLIFY-NEXT: br i1 false, label [[EXIT:%.*]], label [[SCALAR_PH]]
718+ ; UNROLL-NOSIMPLIFY: scalar.ph:
719+ ; UNROLL-NOSIMPLIFY-NEXT: [[BC_RESUME_VAL:%.*]] = phi i16 [ 99, [[MIDDLE_BLOCK]] ], [ 1, [[ENTRY:%.*]] ]
720+ ; UNROLL-NOSIMPLIFY-NEXT: br label [[LOOP_HEADER:%.*]]
721+ ; UNROLL-NOSIMPLIFY: loop.header:
722+ ; UNROLL-NOSIMPLIFY-NEXT: [[IV:%.*]] = phi i16 [ [[BC_RESUME_VAL]], [[SCALAR_PH]] ], [ [[INC:%.*]], [[LOOP_LATCH:%.*]] ]
723+ ; UNROLL-NOSIMPLIFY-NEXT: br i1 [[C]], label [[THEN:%.*]], label [[LOOP_LATCH]]
724+ ; UNROLL-NOSIMPLIFY: then:
725+ ; UNROLL-NOSIMPLIFY-NEXT: [[DIV:%.*]] = sdiv i16 10, [[TMP0]]
726+ ; UNROLL-NOSIMPLIFY-NEXT: store i16 [[DIV]], ptr [[DST]], align 1
727+ ; UNROLL-NOSIMPLIFY-NEXT: br label [[LOOP_LATCH]]
728+ ; UNROLL-NOSIMPLIFY: loop.latch:
729+ ; UNROLL-NOSIMPLIFY-NEXT: [[INC]] = add i16 [[IV]], 1
730+ ; UNROLL-NOSIMPLIFY-NEXT: [[EC:%.*]] = icmp eq i16 [[INC]], 100
731+ ; UNROLL-NOSIMPLIFY-NEXT: br i1 [[EC]], label [[EXIT]], label [[LOOP_HEADER]], !llvm.loop [[LOOP11:![0-9]+]]
732+ ; UNROLL-NOSIMPLIFY: exit:
733+ ; UNROLL-NOSIMPLIFY-NEXT: ret void
734+ ;
735+ ; VEC-LABEL: @sdiv_with_uniform_ops(
736+ ; VEC-NEXT: entry:
737+ ; VEC-NEXT: br label [[VECTOR_BODY:%.*]]
738+ ; VEC: vector.body:
739+ ; VEC-NEXT: [[INDEX:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[INDEX_NEXT:%.*]], [[PRED_STORE_CONTINUE2:%.*]] ]
740+ ; VEC-NEXT: br i1 [[C:%.*]], label [[PRED_STORE_IF:%.*]], label [[PRED_STORE_CONTINUE2]]
741+ ; VEC: pred.store.if:
742+ ; VEC-NEXT: [[TMP1:%.*]] = sdiv i16 10, [[TMP0:%.*]]
743+ ; VEC-NEXT: store i16 [[TMP1]], ptr [[DST:%.*]], align 1
744+ ; VEC-NEXT: [[TMP2:%.*]] = sdiv i16 10, [[TMP0]]
745+ ; VEC-NEXT: store i16 [[TMP2]], ptr [[DST]], align 1
746+ ; VEC-NEXT: br label [[PRED_STORE_CONTINUE2]]
747+ ; VEC: pred.store.continue2:
748+ ; VEC-NEXT: [[INDEX_NEXT]] = add nuw i32 [[INDEX]], 2
749+ ; VEC-NEXT: [[TMP3:%.*]] = icmp eq i32 [[INDEX_NEXT]], 98
750+ ; VEC-NEXT: br i1 [[TMP3]], label [[LOOP_HEADER:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP6:![0-9]+]]
751+ ; VEC: loop.header:
752+ ; VEC-NEXT: [[IV:%.*]] = phi i16 [ [[INC:%.*]], [[LOOP_LATCH:%.*]] ], [ 99, [[PRED_STORE_CONTINUE2]] ]
753+ ; VEC-NEXT: br i1 [[C]], label [[THEN:%.*]], label [[LOOP_LATCH]]
754+ ; VEC: then:
755+ ; VEC-NEXT: [[DIV:%.*]] = sdiv i16 10, [[TMP0]]
756+ ; VEC-NEXT: store i16 [[DIV]], ptr [[DST]], align 1
757+ ; VEC-NEXT: br label [[LOOP_LATCH]]
758+ ; VEC: loop.latch:
759+ ; VEC-NEXT: [[INC]] = add i16 [[IV]], 1
760+ ; VEC-NEXT: [[EC:%.*]] = icmp eq i16 [[INC]], 100
761+ ; VEC-NEXT: br i1 [[EC]], label [[EXIT:%.*]], label [[LOOP_HEADER]], !llvm.loop [[LOOP7:![0-9]+]]
762+ ; VEC: exit:
763+ ; VEC-NEXT: ret void
764+ ;
765+ entry:
766+ br label %loop.header
767+
768+ loop.header:
769+ %iv = phi i16 [ 1 , %entry ], [ %inc , %loop.latch ]
770+ br i1 %c , label %then , label %loop.latch
771+
772+ then:
773+ %div = sdiv i16 10 , %0
774+ store i16 %div , ptr %dst , align 1
775+ br label %loop.latch
776+
777+ loop.latch:
778+ %inc = add i16 %iv , 1
779+ %ec = icmp eq i16 %inc , 100
780+ br i1 %ec , label %exit , label %loop.header
781+
782+ exit:
783+ ret void
784+ }
0 commit comments