Changeset 3927 for trunk


Ignore:
Timestamp:
Jul 24, 2014, 6:21:23 PM (4 years ago)
Author:
linmengl
Message:

use a better ifh_1

Location:
trunk/lib_ir
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib_ir/CMakeLists.txt

    r3925 r3927  
    33
    44set(CXX_SSE_FLAGS "-msse2 -march=pentium4")
     5# perf_flags for xmlwf perf script
     6set(CXX_PERF_FLAGS "-DBUFFER_PROFILING -DPERF_SCRIPT")
    57set(CMAKE_CXX_FLAGS "${CXX_SSE_FLAGS} -std=c++11 ")
    68
    79set(LLVM_OPT "opt-svn")
    810set(LLVM_LLC "llc-svn")
    9 set(LLVM_SSE_FLAGS "-mattr=+sse2,-avx,-avx2,-sse3,-sse4.1,-sse4.2,-sse4a,-ssse3")
     11
     12set(LLVM_SSE_FLAGS "-mattr=+sse,+sse2,-avx,-avx2,-sse3,-sse4.1,-sse4.2,-sse4a,-ssse3")
     13set(LLVM_LLC_FLAGS )#-x86-experimental-vector-shuffle-lowering)
    1014
    1115add_executable(test_s2p test_s2p.cpp s2p_optimized.o)
     
    1923set_target_properties(xmlwf_perf
    2024  PROPERTIES
    21   COMPILE_FLAGS "-DBUFFER_PROFILING -DPERF_SCRIPT"
     25  COMPILE_FLAGS ${CXX_PERF_FLAGS}
    2226  )
     27
     28add_custom_target(asm_s2p
     29  COMMAND ${LLVM_LLC} -O3 ${LLVM_SSE_FLAGS} s2p_optimized.bc
     30  DEPENDS s2p_optimized.bc)
    2331
    2432# compile s2p.ll, and make sure test_s2p depends on it.
    2533add_custom_command(
    26   OUTPUT  s2p_optimized.o
    27   COMMAND ${LLVM_OPT} -O3 ${LLVM_SSE_FLAGS} ${PROJECT_SOURCE_DIR}/s2p.ll -o s2p_optimized.bc
     34  OUTPUT  s2p_optimized.o s2p_optimized.bc
     35  COMMAND ${LLVM_OPT} -O3 -std-compile-opts ${LLVM_SSE_FLAGS} ${PROJECT_SOURCE_DIR}/s2p.ll -o s2p_optimized.bc
    2836  COMMAND ${LLVM_LLC} -O3 ${LLVM_SSE_FLAGS} -filetype=obj s2p_optimized.bc
    2937  DEPENDS ${PROJECT_SOURCE_DIR}/s2p.ll)
     
    5058  COMMAND python ${PROJECT_SOURCE_DIR}/xmlwf/perf_script.py
    5159  DEPENDS xmlwf_perf)
     60
     61
     62# Try IR inline. Compile the whole xmlwf in IR and inline s2p into it.
     63set(LLVM_LINK "llvm-link")
     64set(LLVM_CLANG "/usr/local/bin/clang")
     65# cxx_include should only be used for ir_inline approach.
     66set(CXX_INCLUDE -I${PROJECT_SOURCE_DIR}/xmlwf/util -I${PROJECT_SOURCE_DIR}/xmlwf/lib)
     67
     68add_custom_target(xmlwf_ir_inline
     69  COMMAND ${LLVM_LINK} ${PROJECT_SOURCE_DIR}/s2p.ll xmlwf.ll -o xmlwf_all.bc
     70  COMMAND ${LLVM_OPT} -O3 -std-compile-opts -std-link-opts xmlwf_all.bc -o xmlwf_ir_inline.bc
     71  COMMAND ${LLVM_LLC} -O3 ${LLVM_SSE_FLAGS} -filetype=obj xmlwf_ir_inline.bc
     72  COMMAND ${CMAKE_CXX_COMPILER} xmlwf_ir_inline.o -o xmlwf_ir_inline
     73  DEPENDS s2p.ll xmlwf.ll)
     74
     75add_custom_command(
     76  OUTPUT xmlwf.ll
     77  COMMAND ${LLVM_CLANG} -S -emit-llvm ${CXX_INCLUDE} ${PROJECT_SOURCE_DIR}/xmlwf/src/xmlwf.cpp ${CXX_PERF_FLAGS} -o xmlwf.ll
     78  DEPENDS xmlwf/src/xmlwf.cpp)
     79
  • trunk/lib_ir/s2p.ll

    r3920 r3927  
    3434define <4 x i32> @ifh_1(<4 x i32> %cond, <4 x i32> %b, <4 x i32> %c) alwaysinline {
    3535entry:
    36   %mm = bitcast <4 x i32> %cond to <128 x i1>
    37   %bb = bitcast <4 x i32> %b to <128 x i1>
    38   %cc = bitcast <4 x i32> %c to <128 x i1>
    39 
    40   %rr = select <128 x i1> %mm, <128 x i1> %bb, <128 x i1> %cc
    41   %r  = bitcast <128 x i1> %rr to <4 x i32>
     36  %not_cond = xor <4 x i32> %cond, <i32 -1, i32 -1, i32 -1, i32 -1>
     37
     38  %t0 = and <4 x i32> %cond, %b
     39  %t1 = and <4 x i32> %not_cond, %c
     40  %r = or <4 x i32> %t0, %t1
     41
    4242  ret <4 x i32> %r
    4343}
Note: See TracChangeset for help on using the changeset viewer.