Skip to content

Commit 19199a6

Browse files
author
Kyrylo Tkachov
committed
aarch64: PR target/99822 Don't allow zero register in first operand of SUBS/ADDS-immediate
In this PR we end up generating an invalid instruction: adds x1,xzr,#2 because the pattern accepts zero as an operand in the comparison, but the instruction doesn't. Fix it by adjusting the predicate and constraints. gcc/ChangeLog: PR target/99822 * config/aarch64/aarch64.md (sub<mode>3_compare1_imm): Do not allow zero in operand 1. gcc/testsuite/ChangeLog: PR target/99822 * gcc.c-torture/compile/pr99822.c: New test.
1 parent f64b915 commit 19199a6

File tree

2 files changed

+42
-1
lines changed

2 files changed

+42
-1
lines changed

gcc/config/aarch64/aarch64.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3034,7 +3034,7 @@
30343034
(define_insn "sub<mode>3_compare1_imm"
30353035
[(set (reg:CC CC_REGNUM)
30363036
(compare:CC
3037-
(match_operand:GPI 1 "aarch64_reg_or_zero" "rkZ,rkZ")
3037+
(match_operand:GPI 1 "register_operand" "rk,rk")
30383038
(match_operand:GPI 2 "aarch64_plus_immediate" "I,J")))
30393039
(set (match_operand:GPI 0 "register_operand" "=r,r")
30403040
(plus:GPI
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/* PR target/99822 */
2+
/* { dg-do assemble } */
3+
/* { dg-require-effective-target int128 } */
4+
5+
int zt, bm, p5 = 1;
6+
7+
void __attribute__ ((cold))
8+
l2 (unsigned long int hz)
9+
{
10+
__int128 d9 = 0;
11+
unsigned long int *mg = hz ? &hz : (unsigned long int *) &d9;
12+
13+
while (d9 < 1)
14+
{
15+
bm = bm > d9;
16+
bm = bm == (d9 = bm || hz);
17+
18+
hz = 0x197000000;
19+
d9 = hz * hz;
20+
21+
while (p5 < 1)
22+
{
23+
bm = ((hz = 3) ? zt : 0) > 0x1001;
24+
if (bm != 0)
25+
{
26+
__int128 *nd = (__int128 *) bm;
27+
28+
*nd /= 3;
29+
}
30+
31+
*mg = 0x1001;
32+
p5 -= *mg;
33+
}
34+
35+
for (zt = 0; zt >= 0; zt += 2)
36+
d9 = 0;
37+
38+
d9 += 2;
39+
}
40+
}
41+

0 commit comments

Comments
 (0)