https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92448

            Bug ID: 92448
           Summary: Confusing using of TARGET_PREFER_AVX128
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: crazylht at gmail dot com
                CC: hjl.tools at gmail dot com, rguenth at gcc dot gnu.org,
                    uros at gcc dot gnu.org
  Target Milestone: ---
            Target: i386, x86-64

In x86 backend, we have 2 macros related to 128-bit vectorization, one is
TARGET_AVX128_OPTIMAL which is a tune option.
--------------------
#define TARGET_AVX128_OPTIMAL \                                                 
         ix86_tune_features[X86_TUNE_AVX128_OPTIMAL]

/* X86_TUNE_AVX128_OPTIMAL: Enable 128-bit AVX instruction generation for       
   the auto-vectorizer.  */                                                     
DEF_TUNE (X86_TUNE_AVX128_OPTIMAL, "avx128_optimal", m_BDVER | m_BTVER2         
          | m_ZNVER1 | m_CORE_AVX)  
-------------------

another is TARGET_PREFER_AVX128
------------------
/* Use 128-bit AVX instructions in the auto-vectorizer.  */                     
#define TARGET_PREFER_AVX128    (prefer_vector_width_type == PVW_AVX128)  
-------------------

As my understanding, TARGET_PREFER_AVX128 only related to vector width choosing
in auto vectorization, it shouldn't be used for insntruction generation in md
file.
but I find many using of TARGET_PREFER_AVX128/256 in sse.md and i386.md which
makes it quite confusing.
----------------------
 grep --color -nH -e TARGET_PREFER_AVX *.md                                     
 i386.md:3534:                     (not (match_test "TARGET_PREFER_AVX256")))   
 i386.md:3551:            (cond [(and (ior (not (match_test
"TARGET_PREFER_AVX256"))                                                        
 i386.md:3716:                     (not (match_test "TARGET_PREFER_AVX256")))   
 i386.md:3738:            (cond [(and (ior (not (match_test
"TARGET_PREFER_AVX256"))                                                        
 sse.md:7052:  if (TARGET_AVX && !TARGET_PREFER_AVX128 &&
optimize_insn_for_speed_p ())                                                   
sse.md:7114:  if (TARGET_AVX && !TARGET_PREFER_AVX128 &&
optimize_insn_for_speed_p ())                                                   
sse.md:7229:  if (TARGET_AVX && !TARGET_PREFER_AVX128 &&
optimize_insn_for_speed_p ())                                                   
sse.md:17996:      && TARGET_AVX && !TARGET_PREFER_AVX128 &&
optimize_insn_for_speed_p ())                                                   
sse.md:18128:      && TARGET_AVX && !TARGET_PREFER_AVX128 &&
optimize_insn_for_speed_p ())   
----------------------

Should we change those TARGET_PREFER_AVX128 to TARGET_AVX128_OPTIMAL in *.md
files? So did TARGET_PREFER_AVX256.

Reply via email to