aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoger Sayle <roger@nextmovesoftware.com>2024-06-20 16:30:15 +0100
committerRoger Sayle <roger@nextmovesoftware.com>2024-06-20 16:30:15 +0100
commit9a76db24e044c8058497051a652cca4228cbc8e9 (patch)
treef202e216b630d1506389e4bf59309f9b4961d724
parentf739ad5e35b0a60dec65bb12f8d07aadd0c98196 (diff)
downloadgcc-9a76db24e044c8058497051a652cca4228cbc8e9.zip
gcc-9a76db24e044c8058497051a652cca4228cbc8e9.tar.gz
gcc-9a76db24e044c8058497051a652cca4228cbc8e9.tar.bz2
i386: Allow all register_operand SUBREGs in x86_ternlog_idx.
This patch tweaks ix86_ternlog_idx to allow any SUBREG that matches the register_operand predicate, and is split out as an independent piece of a patch that I have to clean-up redundant ternlog patterns in sse.md. It turns out that some of these patterns aren't (yet) sufficiently redundant to be obsolete. The problem is that the "new" ternlog pattern has the restriction that it allows SUBREGs, but only those where the inner and outer modes are the same size, where regular patterns use "register_operand" which allows arbitrary including paradoxical SUBREGs. A motivating example is f2 in gcc.target/i386/avx512dq-abs-copysign-1.c void f2 (float x, float y) { register float a __asm ("xmm16"), b __asm ("xmm17"); a = x; b = y; asm volatile ("" : "+v" (a), "+v" (b)); a = __builtin_copysignf (a, b); asm volatile ("" : "+v" (a)); } for which combine tries: (set (subreg:V4SF (reg:SF 100 [ _3 ]) 0) (ior:V4SF (and:V4SF (not:V4SF (reg:V4SF 104)) (subreg:V4SF (reg:SF 110) 0)) (reg:V4SF 106))) where the SUBREG is paradoxical, with inner mode SF and outer mode V4SF. This patch allows the recently added ternlog_operand to accept this case. 2024-06-20 Roger Sayle <roger@nextmovesoftware.com> gcc/ChangeLog * config/i386/i386-expand.cc (ix86_ternlog_idx): Allow any SUBREG that matches register_operand. Use rtx_equal_p to compare REG or SUBREG "leaf" operands.
-rw-r--r--gcc/config/i386/i386-expand.cc17
1 files changed, 8 insertions, 9 deletions
diff --git a/gcc/config/i386/i386-expand.cc b/gcc/config/i386/i386-expand.cc
index 5c29ee1..ac42300 100644
--- a/gcc/config/i386/i386-expand.cc
+++ b/gcc/config/i386/i386-expand.cc
@@ -25576,27 +25576,32 @@ ix86_ternlog_idx (rtx op, rtx *args)
switch (GET_CODE (op))
{
+ case SUBREG:
+ if (!register_operand (op, GET_MODE (op)))
+ return -1;
+ /* FALLTHRU */
+
case REG:
if (!args[0])
{
args[0] = op;
return 0xf0;
}
- if (REGNO (op) == REGNO (args[0]))
+ if (rtx_equal_p (op, args[0]))
return 0xf0;
if (!args[1])
{
args[1] = op;
return 0xcc;
}
- if (REGNO (op) == REGNO (args[1]))
+ if (rtx_equal_p (op, args[1]))
return 0xcc;
if (!args[2])
{
args[2] = op;
return 0xaa;
}
- if (REG_P (args[2]) && REGNO (op) == REGNO (args[2]))
+ if (rtx_equal_p (op, args[2]))
return 0xaa;
return -1;
@@ -25634,12 +25639,6 @@ ix86_ternlog_idx (rtx op, rtx *args)
return 0x55;
return -1;
- case SUBREG:
- if (GET_MODE_SIZE (GET_MODE (SUBREG_REG (op)))
- != GET_MODE_SIZE (GET_MODE (op)))
- return -1;
- return ix86_ternlog_idx (SUBREG_REG (op), args);
-
case NOT:
idx0 = ix86_ternlog_idx (XEXP (op, 0), args);
return (idx0 >= 0) ? idx0 ^ 0xff : -1;