From 017dee0c9ee946e16fbb1b938c1dd62ac0f95b09 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Fri, 6 Aug 2021 12:32:01 -0700
Subject: [PATCH v2] x86: Optimize load of const all 1s float vectors
Check float_vector_all_ones_operand for vector floating-point modes to
optimize load of const all 1s float vectors.
gcc/
PR target/101804
* config/i386/constraints.md (BC): For vector floating-point
modes, also check float_vector_all_ones_operand.
* config/i386/i386.c (standard_sse_constant_p): Likewise.
(standard_sse_constant_opcode): Likewise.
gcc/testsuite/
PR target/101804
* gcc.target/i386/avx2-gather-2.c: Pass -march=skylake instead
of "-mavx2 -mtune=skylake". Scan vpcmpeqd.
---
gcc/config/i386/constraints.md | 4 +++-
gcc/config/i386/i386.c | 11 +++++++++--
gcc/testsuite/gcc.target/i386/avx2-gather-2.c | 3 ++-
3 files changed, 14 insertions(+), 4 deletions(-)
@@ -219,7 +219,9 @@ (define_constraint "BC"
"@internal SSE constant -1 operand."
(and (match_test "TARGET_SSE")
(ior (match_test "op == constm1_rtx")
- (match_operand 0 "vector_all_ones_operand"))))
+ (match_operand 0 "vector_all_ones_operand")
+ (and (match_test "GET_MODE_CLASS (mode) == MODE_VECTOR_FLOAT")
+ (match_operand 0 "float_vector_all_ones_operand")))))
;; Integer constant constraints.
(define_constraint "Wb"
@@ -5073,7 +5073,11 @@ standard_sse_constant_p (rtx x, machine_mode pred_mode)
if (x == const0_rtx || const0_operand (x, mode))
return 1;
- if (x == constm1_rtx || vector_all_ones_operand (x, mode))
+ if (x == constm1_rtx
+ || vector_all_ones_operand (x, mode)
+ || ((GET_MODE_CLASS (mode) == MODE_VECTOR_FLOAT
+ || GET_MODE_CLASS (pred_mode) == MODE_VECTOR_FLOAT)
+ && float_vector_all_ones_operand (x, mode)))
{
/* VOIDmode integer constant, get mode from the predicate. */
if (mode == VOIDmode)
@@ -5171,7 +5175,10 @@ standard_sse_constant_opcode (rtx_insn *insn, rtx *operands)
gcc_unreachable ();
}
}
- else if (x == constm1_rtx || vector_all_ones_operand (x, mode))
+ else if (x == constm1_rtx
+ || vector_all_ones_operand (x, mode)
+ || (GET_MODE_CLASS (mode) == MODE_VECTOR_FLOAT
+ && float_vector_all_ones_operand (x, mode)))
{
enum attr_mode insn_mode = get_attr_mode (insn);
@@ -1,6 +1,7 @@
/* { dg-do compile } */
-/* { dg-options "-O3 -mavx2 -fdump-tree-vect-details -mtune=skylake" } */
+/* { dg-options "-O3 -fdump-tree-vect-details -march=skylake" } */
#include "avx2-gather-1.c"
/* { dg-final { scan-tree-dump-times "vectorized 1 loops in function" 16 "vect" } } */
+/* { dg-final { scan-assembler "vpcmpeqd" } } */
--
2.31.1