Skip to content

Commit bc032c7

Browse files
committed
[InstCombine] add tests for div with shl operands; NFC
1 parent 7883900 commit bc032c7

File tree

1 file changed

+136
-0
lines changed

1 file changed

+136
-0
lines changed

llvm/test/Transforms/InstCombine/div-shift.ll

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,3 +741,139 @@ define i8 @sdiv_lshr_mul_nsw(i8 %x, i8 %y, i8 %z) {
741741
%div = sdiv i8 %s, %x
742742
ret i8 %div
743743
}
744+
745+
define i8 @sdiv_shl_shl_nsw2_nuw(i8 %x, i8 %y, i8 %z) {
746+
; CHECK-LABEL: @sdiv_shl_shl_nsw2_nuw(
747+
; CHECK-NEXT: [[XZ:%.*]] = shl nsw i8 [[X:%.*]], [[Z:%.*]]
748+
; CHECK-NEXT: [[YZ:%.*]] = shl nuw nsw i8 [[Y:%.*]], [[Z]]
749+
; CHECK-NEXT: [[D:%.*]] = sdiv i8 [[XZ]], [[YZ]]
750+
; CHECK-NEXT: ret i8 [[D]]
751+
;
752+
%xz = shl nsw i8 %x, %z
753+
%yz = shl nsw nuw i8 %y, %z
754+
%d = sdiv i8 %xz, %yz
755+
ret i8 %d
756+
}
757+
758+
define i8 @sdiv_shl_shl_nsw2_nuw_exact_use(i8 %x, i8 %y, i8 %z) {
759+
; CHECK-LABEL: @sdiv_shl_shl_nsw2_nuw_exact_use(
760+
; CHECK-NEXT: [[XZ:%.*]] = shl nsw i8 [[X:%.*]], [[Z:%.*]]
761+
; CHECK-NEXT: call void @use(i8 [[XZ]])
762+
; CHECK-NEXT: [[YZ:%.*]] = shl nuw nsw i8 [[Y:%.*]], [[Z]]
763+
; CHECK-NEXT: [[D:%.*]] = sdiv exact i8 [[XZ]], [[YZ]]
764+
; CHECK-NEXT: ret i8 [[D]]
765+
;
766+
%xz = shl nsw i8 %x, %z
767+
call void @use(i8 %xz)
768+
%yz = shl nsw nuw i8 %y, %z
769+
%d = sdiv exact i8 %xz, %yz
770+
ret i8 %d
771+
}
772+
773+
define i8 @sdiv_shl_shl_nsw_nuw2(i8 %x, i8 %y, i8 %z) {
774+
; CHECK-LABEL: @sdiv_shl_shl_nsw_nuw2(
775+
; CHECK-NEXT: [[XZ:%.*]] = shl nuw i8 [[X:%.*]], [[Z:%.*]]
776+
; CHECK-NEXT: [[YZ:%.*]] = shl nuw nsw i8 [[Y:%.*]], [[Z]]
777+
; CHECK-NEXT: [[D:%.*]] = sdiv i8 [[XZ]], [[YZ]]
778+
; CHECK-NEXT: ret i8 [[D]]
779+
;
780+
%xz = shl nuw i8 %x, %z
781+
%yz = shl nsw nuw i8 %y, %z
782+
%d = sdiv i8 %xz, %yz
783+
ret i8 %d
784+
}
785+
786+
define i8 @sdiv_shl_shl_nsw_nuw(i8 %x, i8 %y, i8 %z) {
787+
; CHECK-LABEL: @sdiv_shl_shl_nsw_nuw(
788+
; CHECK-NEXT: [[XZ:%.*]] = shl nsw i8 [[X:%.*]], [[Z:%.*]]
789+
; CHECK-NEXT: [[YZ:%.*]] = shl nuw i8 [[Y:%.*]], [[Z]]
790+
; CHECK-NEXT: [[D:%.*]] = sdiv i8 [[XZ]], [[YZ]]
791+
; CHECK-NEXT: ret i8 [[D]]
792+
;
793+
%xz = shl nsw i8 %x, %z
794+
%yz = shl nuw i8 %y, %z
795+
%d = sdiv i8 %xz, %yz
796+
ret i8 %d
797+
}
798+
799+
define i8 @sdiv_shl_shl_nuw_nsw2(i8 %x, i8 %y, i8 %z) {
800+
; CHECK-LABEL: @sdiv_shl_shl_nuw_nsw2(
801+
; CHECK-NEXT: [[XZ:%.*]] = shl nuw nsw i8 [[X:%.*]], [[Z:%.*]]
802+
; CHECK-NEXT: [[YZ:%.*]] = shl nsw i8 [[Y:%.*]], [[Z]]
803+
; CHECK-NEXT: [[D:%.*]] = sdiv i8 [[XZ]], [[YZ]]
804+
; CHECK-NEXT: ret i8 [[D]]
805+
;
806+
%xz = shl nuw nsw i8 %x, %z
807+
%yz = shl nsw i8 %y, %z
808+
%d = sdiv i8 %xz, %yz
809+
ret i8 %d
810+
}
811+
812+
define <2 x i8> @udiv_shl_shl_nuw2(<2 x i8> %x, <2 x i8> %y, <2 x i8> %z) {
813+
; CHECK-LABEL: @udiv_shl_shl_nuw2(
814+
; CHECK-NEXT: [[XZ:%.*]] = shl nuw <2 x i8> [[X:%.*]], [[Z:%.*]]
815+
; CHECK-NEXT: [[YZ:%.*]] = shl nuw <2 x i8> [[Y:%.*]], [[Z]]
816+
; CHECK-NEXT: [[D:%.*]] = udiv <2 x i8> [[XZ]], [[YZ]]
817+
; CHECK-NEXT: ret <2 x i8> [[D]]
818+
;
819+
%xz = shl nuw <2 x i8> %x, %z
820+
%yz = shl nuw <2 x i8> %y, %z
821+
%d = udiv <2 x i8> %xz, %yz
822+
ret <2 x i8> %d
823+
}
824+
825+
define i8 @udiv_shl_shl_nuw2_exact_use2(i8 %x, i8 %y, i8 %z) {
826+
; CHECK-LABEL: @udiv_shl_shl_nuw2_exact_use2(
827+
; CHECK-NEXT: [[XZ:%.*]] = shl nuw i8 [[X:%.*]], [[Z:%.*]]
828+
; CHECK-NEXT: call void @use(i8 [[XZ]])
829+
; CHECK-NEXT: [[YZ:%.*]] = shl nuw i8 [[Y:%.*]], [[Z]]
830+
; CHECK-NEXT: call void @use(i8 [[YZ]])
831+
; CHECK-NEXT: [[D:%.*]] = udiv exact i8 [[XZ]], [[YZ]]
832+
; CHECK-NEXT: ret i8 [[D]]
833+
;
834+
%xz = shl nuw i8 %x, %z
835+
call void @use(i8 %xz)
836+
%yz = shl nuw i8 %y, %z
837+
call void @use(i8 %yz)
838+
%d = udiv exact i8 %xz, %yz
839+
ret i8 %d
840+
}
841+
842+
define i8 @udiv_shl_shl_nuw_nsw(i8 %x, i8 %y, i8 %z) {
843+
; CHECK-LABEL: @udiv_shl_shl_nuw_nsw(
844+
; CHECK-NEXT: [[XZ:%.*]] = shl nuw i8 [[X:%.*]], [[Z:%.*]]
845+
; CHECK-NEXT: [[YZ:%.*]] = shl nsw i8 [[Y:%.*]], [[Z]]
846+
; CHECK-NEXT: [[D:%.*]] = udiv i8 [[XZ]], [[YZ]]
847+
; CHECK-NEXT: ret i8 [[D]]
848+
;
849+
%xz = shl nuw i8 %x, %z
850+
%yz = shl nsw i8 %y, %z
851+
%d = udiv i8 %xz, %yz
852+
ret i8 %d
853+
}
854+
855+
define i8 @udiv_shl_shl_nsw_nuw(i8 %x, i8 %y, i8 %z) {
856+
; CHECK-LABEL: @udiv_shl_shl_nsw_nuw(
857+
; CHECK-NEXT: [[XZ:%.*]] = shl nsw i8 [[X:%.*]], [[Z:%.*]]
858+
; CHECK-NEXT: [[YZ:%.*]] = shl nuw i8 [[Y:%.*]], [[Z]]
859+
; CHECK-NEXT: [[D:%.*]] = udiv i8 [[XZ]], [[YZ]]
860+
; CHECK-NEXT: ret i8 [[D]]
861+
;
862+
%xz = shl nsw i8 %x, %z
863+
%yz = shl nuw i8 %y, %z
864+
%d = udiv i8 %xz, %yz
865+
ret i8 %d
866+
}
867+
868+
define i8 @udiv_shl_shl_nuw_nsw2(i8 %x, i8 %y, i8 %z) {
869+
; CHECK-LABEL: @udiv_shl_shl_nuw_nsw2(
870+
; CHECK-NEXT: [[XZ:%.*]] = shl nuw nsw i8 [[X:%.*]], [[Z:%.*]]
871+
; CHECK-NEXT: [[YZ:%.*]] = shl nsw i8 [[Y:%.*]], [[Z]]
872+
; CHECK-NEXT: [[D:%.*]] = udiv i8 [[XZ]], [[YZ]]
873+
; CHECK-NEXT: ret i8 [[D]]
874+
;
875+
%xz = shl nuw nsw i8 %x, %z
876+
%yz = shl nsw i8 %y, %z
877+
%d = udiv i8 %xz, %yz
878+
ret i8 %d
879+
}

0 commit comments

Comments
 (0)