public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-2188] i386: Fix *udivmodsi4_pow2_zext_? patterns
@ 2021-07-09 9:46 Uros Bizjak
0 siblings, 0 replies; only message in thread
From: Uros Bizjak @ 2021-07-09 9:46 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:10722fb36de944c2385a275bb2b270727f7c93a4
commit r12-2188-g10722fb36de944c2385a275bb2b270727f7c93a4
Author: Uros Bizjak <ubizjak@gmail.com>
Date: Fri Jul 9 11:45:54 2021 +0200
i386: Fix *udivmodsi4_pow2_zext_? patterns
In addition to the obvious cut-n-pasto where *udivmodsi4_pow2_zext_2
never matches, limit the range of the immediate operand to prevent
out of range immediate operand of AND instruction.
Found by inspection, the patterns rarely match (if at all), since
tree optimizers do the transformation before RTL is generated. But
according to the comment above *udivmod<mode>4_pow2, the constant can
materialize after expansion, so leave these patterns around for now.
2021-07-09 Uroš Bizjak <ubizjak@gmail.com>
gcc/
* config/i386/i386.md (*udivmodsi4_pow2_zext_1): Limit the
log2 range of operands[3] to [1,31].
(*udivmodsi4_pow2_zext_2): Ditto. Correct insn RTX pattern.
Diff:
---
gcc/config/i386/i386.md | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
index 156c6a94989..26fb81b9b4b 100644
--- a/gcc/config/i386/i386.md
+++ b/gcc/config/i386/i386.md
@@ -8518,7 +8518,7 @@
(umod:SI (match_dup 2) (match_dup 3)))
(clobber (reg:CC FLAGS_REG))]
"TARGET_64BIT
- && exact_log2 (UINTVAL (operands[3])) > 0"
+ && IN_RANGE (exact_log2 (UINTVAL (operands[3])), 1, 31)"
"#"
"&& reload_completed"
[(set (match_dup 1) (match_dup 2))
@@ -8599,10 +8599,10 @@
(umod:SI (match_operand:SI 2 "register_operand" "0")
(match_operand:SI 3 "const_int_operand" "n"))))
(set (match_operand:SI 0 "register_operand" "=r")
- (umod:SI (match_dup 2) (match_dup 3)))
+ (udiv:SI (match_dup 2) (match_dup 3)))
(clobber (reg:CC FLAGS_REG))]
"TARGET_64BIT
- && exact_log2 (UINTVAL (operands[3])) > 0"
+ && IN_RANGE (exact_log2 (UINTVAL (operands[3])), 1, 31)"
"#"
"&& reload_completed"
[(set (match_dup 1) (match_dup 2))
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-07-09 9:46 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-09 9:46 [gcc r12-2188] i386: Fix *udivmodsi4_pow2_zext_? patterns Uros Bizjak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).