@@ -1664,5 +1664,167 @@ for.body:
16641664 br i1 %cmp , label %for.body , label %for.cond.cleanup
16651665}
16661666
1667+ define i64 @test_std_q31 (ptr %x , i32 %n ) #0 {
1668+ ; CHECK-LABEL: @test_std_q31(
1669+ ; CHECK-NEXT: entry:
1670+ ; CHECK-NEXT: [[CMP11:%.*]] = icmp sgt i32 [[N:%.*]], 0
1671+ ; CHECK-NEXT: tail call void @llvm.assume(i1 [[CMP11]])
1672+ ; CHECK-NEXT: br label [[FOR_BODY1:%.*]]
1673+ ; CHECK: for.cond.cleanup:
1674+ ; CHECK-NEXT: [[DIV:%.*]] = sdiv i64 [[ADD3:%.*]], [[ADD:%.*]]
1675+ ; CHECK-NEXT: ret i64 [[DIV]]
1676+ ; CHECK: for.body:
1677+ ; CHECK-NEXT: [[S_014:%.*]] = phi i64 [ [[ADD]], [[FOR_BODY1]] ], [ 0, [[ENTRY:%.*]] ]
1678+ ; CHECK-NEXT: [[I_013:%.*]] = phi i32 [ [[ADD4:%.*]], [[FOR_BODY1]] ], [ 0, [[ENTRY]] ]
1679+ ; CHECK-NEXT: [[T_012:%.*]] = phi i64 [ [[ADD3]], [[FOR_BODY1]] ], [ 0, [[ENTRY]] ]
1680+ ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, ptr [[X:%.*]], i32 [[I_013]]
1681+ ; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[ARRAYIDX]], align 4
1682+ ; CHECK-NEXT: [[SHR:%.*]] = ashr i32 [[TMP0]], 8
1683+ ; CHECK-NEXT: [[CONV:%.*]] = sext i32 [[SHR]] to i64
1684+ ; CHECK-NEXT: [[ADD]] = add nsw i64 [[S_014]], [[CONV]]
1685+ ; CHECK-NEXT: [[MUL:%.*]] = mul nsw i64 [[CONV]], [[CONV]]
1686+ ; CHECK-NEXT: [[ADD3]] = add nuw nsw i64 [[MUL]], [[T_012]]
1687+ ; CHECK-NEXT: [[ADD4]] = add nuw nsw i32 [[I_013]], 1
1688+ ; CHECK-NEXT: [[EXITCOND_NOT:%.*]] = icmp eq i32 [[ADD4]], [[N]]
1689+ ; CHECK-NEXT: br i1 [[EXITCOND_NOT]], label [[FOR_COND_CLEANUP:%.*]], label [[FOR_BODY1]]
1690+ ;
1691+ entry:
1692+ %cmp11 = icmp sgt i32 %n , 0
1693+ tail call void @llvm.assume (i1 %cmp11 )
1694+ br label %for.body
1695+
1696+ for.cond.cleanup: ; preds = %for.body
1697+ %div = sdiv i64 %add3 , %add
1698+ ret i64 %div
1699+
1700+ for.body: ; preds = %entry, %for.body
1701+ %s.014 = phi i64 [ %add , %for.body ], [ 0 , %entry ]
1702+ %i.013 = phi i32 [ %add4 , %for.body ], [ 0 , %entry ]
1703+ %t.012 = phi i64 [ %add3 , %for.body ], [ 0 , %entry ]
1704+ %arrayidx = getelementptr inbounds i32 , ptr %x , i32 %i.013
1705+ %0 = load i32 , ptr %arrayidx , align 4
1706+ %shr = ashr i32 %0 , 8
1707+ %conv = sext i32 %shr to i64
1708+ %add = add nsw i64 %s.014 , %conv
1709+ %mul = mul nsw i64 %conv , %conv
1710+ %add3 = add nuw nsw i64 %mul , %t.012
1711+ %add4 = add nuw nsw i32 %i.013 , 1
1712+ %exitcond.not = icmp eq i32 %add4 , %n
1713+ br i1 %exitcond.not , label %for.cond.cleanup , label %for.body
1714+ }
1715+
1716+ define i64 @test_fir_q15 (ptr %x , ptr %y , i32 %n ) #0 {
1717+ ; CHECK-LABEL: @test_fir_q15(
1718+ ; CHECK-NEXT: entry:
1719+ ; CHECK-NEXT: [[CMP23:%.*]] = icmp sgt i32 [[N:%.*]], 0
1720+ ; CHECK-NEXT: br i1 [[CMP23]], label [[FOR_BODY_PREHEADER:%.*]], label [[FOR_COND_CLEANUP:%.*]]
1721+ ; CHECK: for.body.preheader:
1722+ ; CHECK-NEXT: [[TMP0:%.*]] = add nsw i32 [[N]], -1
1723+ ; CHECK-NEXT: [[TMP1:%.*]] = lshr i32 [[TMP0]], 1
1724+ ; CHECK-NEXT: [[TMP2:%.*]] = add nuw i32 [[TMP1]], 1
1725+ ; CHECK-NEXT: [[MIN_ITERS_CHECK:%.*]] = icmp ult i32 [[N]], 7
1726+ ; CHECK-NEXT: br i1 [[MIN_ITERS_CHECK]], label [[SCALAR_PH:%.*]], label [[VECTOR_PH:%.*]]
1727+ ; CHECK: vector.ph:
1728+ ; CHECK-NEXT: [[N_VEC:%.*]] = and i32 [[TMP2]], -4
1729+ ; CHECK-NEXT: [[IND_END:%.*]] = shl i32 [[N_VEC]], 1
1730+ ; CHECK-NEXT: br label [[VECTOR_BODY:%.*]]
1731+ ; CHECK: vector.body:
1732+ ; CHECK-NEXT: [[INDEX:%.*]] = phi i32 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ]
1733+ ; CHECK-NEXT: [[VEC_PHI:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[TMP16:%.*]], [[VECTOR_BODY]] ]
1734+ ; CHECK-NEXT: [[OFFSET_IDX:%.*]] = shl i32 [[INDEX]], 1
1735+ ; CHECK-NEXT: [[TMP3:%.*]] = getelementptr inbounds i16, ptr [[X:%.*]], i32 [[OFFSET_IDX]]
1736+ ; CHECK-NEXT: [[WIDE_VEC:%.*]] = load <8 x i16>, ptr [[TMP3]], align 2
1737+ ; CHECK-NEXT: [[STRIDED_VEC:%.*]] = shufflevector <8 x i16> [[WIDE_VEC]], <8 x i16> poison, <4 x i32> <i32 0, i32 2, i32 4, i32 6>
1738+ ; CHECK-NEXT: [[STRIDED_VEC1:%.*]] = shufflevector <8 x i16> [[WIDE_VEC]], <8 x i16> poison, <4 x i32> <i32 1, i32 3, i32 5, i32 7>
1739+ ; CHECK-NEXT: [[TMP5:%.*]] = sext <4 x i16> [[STRIDED_VEC]] to <4 x i32>
1740+ ; CHECK-NEXT: [[TMP4:%.*]] = getelementptr inbounds i16, ptr [[Y:%.*]], i32 [[OFFSET_IDX]]
1741+ ; CHECK-NEXT: [[WIDE_VEC2:%.*]] = load <8 x i16>, ptr [[TMP4]], align 2
1742+ ; CHECK-NEXT: [[STRIDED_VEC3:%.*]] = shufflevector <8 x i16> [[WIDE_VEC2]], <8 x i16> poison, <4 x i32> <i32 0, i32 2, i32 4, i32 6>
1743+ ; CHECK-NEXT: [[STRIDED_VEC4:%.*]] = shufflevector <8 x i16> [[WIDE_VEC2]], <8 x i16> poison, <4 x i32> <i32 1, i32 3, i32 5, i32 7>
1744+ ; CHECK-NEXT: [[TMP6:%.*]] = sext <4 x i16> [[STRIDED_VEC3]] to <4 x i32>
1745+ ; CHECK-NEXT: [[TMP7:%.*]] = mul nsw <4 x i32> [[TMP6]], [[TMP5]]
1746+ ; CHECK-NEXT: [[TMP8:%.*]] = sext <4 x i32> [[TMP7]] to <4 x i64>
1747+ ; CHECK-NEXT: [[TMP13:%.*]] = sext <4 x i16> [[STRIDED_VEC1]] to <4 x i32>
1748+ ; CHECK-NEXT: [[TMP14:%.*]] = sext <4 x i16> [[STRIDED_VEC4]] to <4 x i32>
1749+ ; CHECK-NEXT: [[TMP11:%.*]] = mul nsw <4 x i32> [[TMP14]], [[TMP13]]
1750+ ; CHECK-NEXT: [[TMP12:%.*]] = sext <4 x i32> [[TMP11]] to <4 x i64>
1751+ ; CHECK-NEXT: [[TMP9:%.*]] = call i64 @llvm.vector.reduce.add.v4i64(<4 x i64> [[TMP8]])
1752+ ; CHECK-NEXT: [[TMP10:%.*]] = add i64 [[TMP9]], [[VEC_PHI]]
1753+ ; CHECK-NEXT: [[TMP15:%.*]] = call i64 @llvm.vector.reduce.add.v4i64(<4 x i64> [[TMP12]])
1754+ ; CHECK-NEXT: [[TMP16]] = add i64 [[TMP15]], [[TMP10]]
1755+ ; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i32 [[INDEX]], 4
1756+ ; CHECK-NEXT: [[TMP17:%.*]] = icmp eq i32 [[INDEX_NEXT]], [[N_VEC]]
1757+ ; CHECK-NEXT: br i1 [[TMP17]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP37:![0-9]+]]
1758+ ; CHECK: middle.block:
1759+ ; CHECK-NEXT: [[CMP_N:%.*]] = icmp eq i32 [[TMP2]], [[N_VEC]]
1760+ ; CHECK-NEXT: br i1 [[CMP_N]], label [[FOR_COND_CLEANUP]], label [[SCALAR_PH]]
1761+ ; CHECK: scalar.ph:
1762+ ; CHECK-NEXT: [[BC_RESUME_VAL:%.*]] = phi i32 [ [[IND_END]], [[MIDDLE_BLOCK]] ], [ 0, [[FOR_BODY_PREHEADER]] ]
1763+ ; CHECK-NEXT: [[BC_MERGE_RDX:%.*]] = phi i64 [ [[TMP16]], [[MIDDLE_BLOCK]] ], [ 0, [[FOR_BODY_PREHEADER]] ]
1764+ ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
1765+ ; CHECK: for.cond.cleanup:
1766+ ; CHECK-NEXT: [[S_0_LCSSA:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[ADD12:%.*]], [[FOR_BODY]] ], [ [[TMP16]], [[MIDDLE_BLOCK]] ]
1767+ ; CHECK-NEXT: ret i64 [[S_0_LCSSA]]
1768+ ; CHECK: for.body:
1769+ ; CHECK-NEXT: [[I_025:%.*]] = phi i32 [ [[ADD13:%.*]], [[FOR_BODY]] ], [ [[BC_RESUME_VAL]], [[SCALAR_PH]] ]
1770+ ; CHECK-NEXT: [[S_024:%.*]] = phi i64 [ [[ADD12]], [[FOR_BODY]] ], [ [[BC_MERGE_RDX]], [[SCALAR_PH]] ]
1771+ ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i16, ptr [[X]], i32 [[I_025]]
1772+ ; CHECK-NEXT: [[TMP18:%.*]] = load i16, ptr [[ARRAYIDX]], align 2
1773+ ; CHECK-NEXT: [[CONV:%.*]] = sext i16 [[TMP18]] to i32
1774+ ; CHECK-NEXT: [[ARRAYIDX1:%.*]] = getelementptr inbounds i16, ptr [[Y]], i32 [[I_025]]
1775+ ; CHECK-NEXT: [[TMP19:%.*]] = load i16, ptr [[ARRAYIDX1]], align 2
1776+ ; CHECK-NEXT: [[CONV2:%.*]] = sext i16 [[TMP19]] to i32
1777+ ; CHECK-NEXT: [[MUL:%.*]] = mul nsw i32 [[CONV2]], [[CONV]]
1778+ ; CHECK-NEXT: [[CONV3:%.*]] = sext i32 [[MUL]] to i64
1779+ ; CHECK-NEXT: [[ADD:%.*]] = add nsw i64 [[S_024]], [[CONV3]]
1780+ ; CHECK-NEXT: [[ADD4:%.*]] = or disjoint i32 [[I_025]], 1
1781+ ; CHECK-NEXT: [[ARRAYIDX5:%.*]] = getelementptr inbounds i16, ptr [[X]], i32 [[ADD4]]
1782+ ; CHECK-NEXT: [[TMP20:%.*]] = load i16, ptr [[ARRAYIDX5]], align 2
1783+ ; CHECK-NEXT: [[CONV6:%.*]] = sext i16 [[TMP20]] to i32
1784+ ; CHECK-NEXT: [[ARRAYIDX8:%.*]] = getelementptr inbounds i16, ptr [[Y]], i32 [[ADD4]]
1785+ ; CHECK-NEXT: [[TMP21:%.*]] = load i16, ptr [[ARRAYIDX8]], align 2
1786+ ; CHECK-NEXT: [[CONV9:%.*]] = sext i16 [[TMP21]] to i32
1787+ ; CHECK-NEXT: [[MUL10:%.*]] = mul nsw i32 [[CONV9]], [[CONV6]]
1788+ ; CHECK-NEXT: [[CONV11:%.*]] = sext i32 [[MUL10]] to i64
1789+ ; CHECK-NEXT: [[ADD12]] = add nsw i64 [[ADD]], [[CONV11]]
1790+ ; CHECK-NEXT: [[ADD13]] = add nuw nsw i32 [[I_025]], 2
1791+ ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[ADD13]], [[N]]
1792+ ; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY]], label [[FOR_COND_CLEANUP]], !llvm.loop [[LOOP38:![0-9]+]]
1793+ ;
1794+ entry:
1795+ %cmp23 = icmp sgt i32 %n , 0
1796+ br i1 %cmp23 , label %for.body , label %for.cond.cleanup
1797+
1798+ for.cond.cleanup: ; preds = %for.body, %entry
1799+ %s.0.lcssa = phi i64 [ 0 , %entry ], [ %add12 , %for.body ]
1800+ ret i64 %s.0.lcssa
1801+
1802+ for.body: ; preds = %entry, %for.body
1803+ %i.025 = phi i32 [ %add13 , %for.body ], [ 0 , %entry ]
1804+ %s.024 = phi i64 [ %add12 , %for.body ], [ 0 , %entry ]
1805+ %arrayidx = getelementptr inbounds i16 , ptr %x , i32 %i.025
1806+ %0 = load i16 , ptr %arrayidx , align 2
1807+ %conv = sext i16 %0 to i32
1808+ %arrayidx1 = getelementptr inbounds i16 , ptr %y , i32 %i.025
1809+ %1 = load i16 , ptr %arrayidx1 , align 2
1810+ %conv2 = sext i16 %1 to i32
1811+ %mul = mul nsw i32 %conv2 , %conv
1812+ %conv3 = sext i32 %mul to i64
1813+ %add = add nsw i64 %s.024 , %conv3
1814+ %add4 = or disjoint i32 %i.025 , 1
1815+ %arrayidx5 = getelementptr inbounds i16 , ptr %x , i32 %add4
1816+ %2 = load i16 , ptr %arrayidx5 , align 2
1817+ %conv6 = sext i16 %2 to i32
1818+ %arrayidx8 = getelementptr inbounds i16 , ptr %y , i32 %add4
1819+ %3 = load i16 , ptr %arrayidx8 , align 2
1820+ %conv9 = sext i16 %3 to i32
1821+ %mul10 = mul nsw i32 %conv9 , %conv6
1822+ %conv11 = sext i32 %mul10 to i64
1823+ %add12 = add nsw i64 %add , %conv11
1824+ %add13 = add nuw nsw i32 %i.025 , 2
1825+ %cmp = icmp slt i32 %add13 , %n
1826+ br i1 %cmp , label %for.body , label %for.cond.cleanup
1827+ }
1828+
16671829
16681830attributes #0 = { "target-features" ="+mve" }
0 commit comments