o
    8ήcq
                     @   s   d dl Z d dlZd dlmZ d dlmZmZ d dlm	Z	 d dl
mZmZ d dlmZ dZer:d dlmZ ed	d
 ee  dkdG dd deZdS )    N)types)TestCaseskipIf)override_env_config)compile_isolatedFlags)FastMathOptionsF)binding z--debug-only=loop-vectorizex86_64zx86_64 only testc                   @   s2   e Zd ZdZdddZdd Zdd Zd	d
 ZdS )TestVectorizationzP
    Tests to assert that code which should vectorize does indeed vectorize
    Fc              	   C   s   t dd< t dd& t }t||_d|_t|||d}|j W  d    W  d    S 1 s4w   Y  W d    d S 1 sDw   Y  d S )NNUMBA_CPU_NAMEzskylake-avx512NUMBA_CPU_FEATURESr
   T)flags)r   r   r   fastmathnrtr   libraryget_llvm_str)selffunc
args_tupler   _flagsjitted r   E/tmp/pip-target-vg8gfxp4/lib/python/numba/tests/test_vectorization.pygen_ir   s   
RzTestVectorization.gen_irc                 C   sB   dd }| j |tjd d d fdd}| d| | d| d S )Nc                 S   s$   d}t | D ]}|| 7 }q|S )Nr   )npnditeritem)xaccvr   r   r   do_sum!   s   z2TestVectorization.test_nditer_loop.<locals>.do_sum   Tr   vector.bodyllvm.loop.isvectorized)r   r   float64assertIn)r   r"   llvm_irr   r   r   test_nditer_loop   s   z"TestVectorization.test_nditer_loopc                 C   sD   dd }t j}| j||fd |d d d f dd}| d| d S )Nc                 S   sD   | | |  |d< |||  |d< | | |  |d< |||  |d< d S )Nr   r#         r   )a1a2b1b2Ar   r   r   foo/   s   z'TestVectorization.test_slp.<locals>.foo   r#   Tr$   z
2 x double)r   r'   r   r(   )r   r2   tyr)   r   r   r   test_slp+   s   &zTestVectorization.test_slpc                 C   s>   dd }| j |ttjfdd}| d| | d| d S )Nc                 S   s    d}| D ]	}|t |7 }q|S )Ng        )r   sqrt)lstr    r   r   r   r   sum_sqrt_list@   s   z@TestVectorization.test_instcombine_effect.<locals>.sum_sqrt_listTr$   r%   r&   )r   r   ListTyper'   r(   )r   r8   r)   r   r   r   test_instcombine_effect9   s   z)TestVectorization.test_instcombine_effectN)F)__name__
__module____qualname____doc__r   r*   r5   r:   r   r   r   r   r      s    

r   )platformnumpyr   numbar   unittestr   r   numba.tests.supportr   numba.core.compilerr   r   numba.core.cpu_optionsr   _DEBUGllvmliter	   llvm
set_optionmachiner   r   r   r   r   <module>   s    