Skip to content

Commit aec230e

Browse files
committed
Add GCC patches for HS48 processors
Signed-off-by: Evgeniy Didin <[email protected]>
1 parent 1a3164b commit aec230e

7 files changed

+702
-0
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
From 274a5a1d63fc5e4ea942165702363547e71525ac Mon Sep 17 00:00:00 2001
2+
From: Vineet Gupta <[email protected]>
3+
Date: Fri, 29 Mar 2019 17:45:20 +0200
4+
Subject: [PATCH 1/7] [ARC] PR 88409: miscompilation due to missing cc clobber
5+
in longlong.h macros
6+
7+
simple test such as below was failing.
8+
9+
| void main(int argc, char *argv[])
10+
| {
11+
| size_t total_time = 115424; // expected 115.424
12+
| double secs = (double)total_time/(double)1000;
13+
| printf("%s %d %lf\n", "secs", total_time, secs); // prints 113.504
14+
| printf("%d\n", (size_t)secs);
15+
| }
16+
17+
The printf eventually called into glibc stdlib/divrem.c:__mpn_divrem()
18+
which uses the __arc__ specific inline asm macros from longlong.h which
19+
were causing miscompilation.
20+
21+
include/
22+
2019-03-28 Vineet Gupta <[email protected]>
23+
24+
PR 89877
25+
26+
* longlong.h [__arc__] (add_ssaaaa): Add cc clobber
27+
(sub_ddmmss): Likewise.
28+
29+
Signed-off-by: Claudiu Zissulescu <[email protected]>
30+
---
31+
include/longlong.h | 6 ++++--
32+
1 file changed, 4 insertions(+), 2 deletions(-)
33+
34+
diff --git a/include/longlong.h b/include/longlong.h
35+
index 7f3dc17dc0a..8771365b9dc 100644
36+
--- a/include/longlong.h
37+
+++ b/include/longlong.h
38+
@@ -199,7 +199,8 @@ extern UDItype __udiv_qrnnd (UDItype *, UDItype, UDItype, UDItype);
39+
: "%r" ((USItype) (ah)), \
40+
"rICal" ((USItype) (bh)), \
41+
"%r" ((USItype) (al)), \
42+
- "rICal" ((USItype) (bl)))
43+
+ "rICal" ((USItype) (bl)) \
44+
+ : "cc")
45+
#define sub_ddmmss(sh, sl, ah, al, bh, bl) \
46+
__asm__ ("sub.f %1, %4, %5\n\tsbc %0, %2, %3" \
47+
: "=r" ((USItype) (sh)), \
48+
@@ -207,7 +208,8 @@ extern UDItype __udiv_qrnnd (UDItype *, UDItype, UDItype, UDItype);
49+
: "r" ((USItype) (ah)), \
50+
"rICal" ((USItype) (bh)), \
51+
"r" ((USItype) (al)), \
52+
- "rICal" ((USItype) (bl)))
53+
+ "rICal" ((USItype) (bl)) \
54+
+ : "cc")
55+
56+
#define __umulsidi3(u,v) ((UDItype)(USItype)u*(USItype)v)
57+
#ifdef __ARC_NORM__
58+
--
59+
2.16.2
60+
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
From 4c33b1cb6400341121700473da03d4083990a093 Mon Sep 17 00:00:00 2001
2+
From: Claudiu Zissulescu <[email protected]>
3+
Date: Mon, 1 Apr 2019 13:03:55 +0300
4+
Subject: [PATCH 2/7] [ARC] Fix for PR89838.
5+
6+
gcc/
7+
xxxx-xx-xx Claudiu Zissulescu <[email protected]>
8+
9+
* config/arc/arc.c (arc_legitimize_pic_address): Emit an move
10+
instruction if needed.
11+
(prepare_pic_move): Always provide an spare register.
12+
13+
/gcc/testsuite
14+
xxxx-xx-xx Claudiu Zissulescu <[email protected]>
15+
16+
* gcc.target/arc/pr89838.c: New file.
17+
---
18+
gcc/config/arc/arc.c | 9 ++++++++-
19+
gcc/testsuite/gcc.target/arc/pr89838.c | 16 ++++++++++++++++
20+
2 files changed, 24 insertions(+), 1 deletion(-)
21+
create mode 100644 gcc/testsuite/gcc.target/arc/pr89838.c
22+
23+
diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c
24+
index ba2e3dd8208..83664d4d64f 100644
25+
--- a/gcc/config/arc/arc.c
26+
+++ b/gcc/config/arc/arc.c
27+
@@ -6093,6 +6093,13 @@ arc_legitimize_pic_address (rtx orig, rtx oldx)
28+
if (base == op0 && pat == op1)
29+
return orig;
30+
31+
+ if (GET_CODE (base) == PLUS)
32+
+ {
33+
+ gcc_assert (oldx != NULL_RTX);
34+
+ gcc_assert (REG_P (oldx));
35+
+ emit_insn (gen_rtx_SET (oldx, base));
36+
+ base = oldx;
37+
+ }
38+
if (GET_CODE (pat) == CONST_INT)
39+
pat = plus_constant (Pmode, base, INTVAL (pat));
40+
else
41+
@@ -6285,7 +6292,7 @@ prepare_pic_move (rtx *operands, machine_mode)
42+
else
43+
{
44+
rtx temp = (reload_in_progress ? operands[0]
45+
- : flag_pic? gen_reg_rtx (Pmode) : NULL_RTX);
46+
+ : gen_reg_rtx (Pmode));
47+
operands[1] = arc_legitimize_pic_address (operands[1], temp);
48+
}
49+
}
50+
diff --git a/gcc/testsuite/gcc.target/arc/pr89838.c b/gcc/testsuite/gcc.target/arc/pr89838.c
51+
new file mode 100644
52+
index 00000000000..559434ac87e
53+
--- /dev/null
54+
+++ b/gcc/testsuite/gcc.target/arc/pr89838.c
55+
@@ -0,0 +1,16 @@
56+
+/* { dg-do compile } */
57+
+/* { dg-require-effective-target tls } */
58+
+/* { dg-options "-O2" } */
59+
+
60+
+extern void foo (void);
61+
+extern void bar (void *);
62+
+
63+
+struct {
64+
+ int __attribute__(()) a;
65+
+ int __attribute__(()) b;
66+
+} __thread c __attribute__((tls_model("initial-exec")));
67+
+
68+
+void foo (void)
69+
+{
70+
+ bar (&c.b);
71+
+}
72+
--
73+
2.16.2
74+
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
From 62f2c9d66765c2dbfc0ec895e1242f36bac63cf3 Mon Sep 17 00:00:00 2001
2+
From: Claudiu Zissulescu <[email protected]>
3+
Date: Tue, 2 Apr 2019 15:28:41 +0300
4+
Subject: [PATCH 3/7] [ARC] Cleanup TUNE variants
5+
6+
Cleanup TUNE variants.
7+
8+
gcc/
9+
xxxx-xx-xx Claudiu Zissulescu <[email protected]>
10+
11+
* config/arc/arc.c (arc_sched_issue_rate): Use correct enum.
12+
* config/arc/arc.md (tune): Update tune attribute, and use correct
13+
enums.
14+
(tune_dspmpy): Likewise.
15+
---
16+
gcc/config/arc/arc.c | 4 ++--
17+
gcc/config/arc/arc.md | 22 ++++++++++------------
18+
2 files changed, 12 insertions(+), 14 deletions(-)
19+
20+
diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c
21+
index 83664d4d64f..b428bfbed63 100644
22+
--- a/gcc/config/arc/arc.c
23+
+++ b/gcc/config/arc/arc.c
24+
@@ -490,8 +490,8 @@ arc_sched_issue_rate (void)
25+
{
26+
switch (arc_tune)
27+
{
28+
- case TUNE_ARCHS4X:
29+
- case TUNE_ARCHS4XD:
30+
+ case ARC_TUNE_ARCHS4X:
31+
+ case ARC_TUNE_ARCHS4XD:
32+
return 3;
33+
default:
34+
break;
35+
diff --git a/gcc/config/arc/arc.md b/gcc/config/arc/arc.md
36+
index 241506ea785..42a24e16ff4 100644
37+
--- a/gcc/config/arc/arc.md
38+
+++ b/gcc/config/arc/arc.md
39+
@@ -621,22 +621,20 @@
40+
;; is made that makes conditional execution required.
41+
42+
(define_attr "tune" "none,arc600,arc7xx,arc700_4_2_std,arc700_4_2_xmac, \
43+
-core_3, archs4x, archs4xd, archs4xd_slow"
44+
+archs4x, archs4xd"
45+
(const
46+
- (cond [(symbol_ref "arc_tune == TUNE_ARC600")
47+
+ (cond [(symbol_ref "arc_tune == ARC_TUNE_ARC600")
48+
(const_string "arc600")
49+
(symbol_ref "arc_tune == ARC_TUNE_ARC7XX")
50+
(const_string "arc7xx")
51+
- (symbol_ref "arc_tune == TUNE_ARC700_4_2_STD")
52+
+ (symbol_ref "arc_tune == ARC_TUNE_ARC700_4_2_STD")
53+
(const_string "arc700_4_2_std")
54+
- (symbol_ref "arc_tune == TUNE_ARC700_4_2_XMAC")
55+
+ (symbol_ref "arc_tune == ARC_TUNE_ARC700_4_2_XMAC")
56+
(const_string "arc700_4_2_xmac")
57+
- (symbol_ref "arc_tune == ARC_TUNE_CORE_3")
58+
- (const_string "core_3")
59+
- (symbol_ref "arc_tune == TUNE_ARCHS4X")
60+
+ (symbol_ref "arc_tune == ARC_TUNE_ARCHS4X")
61+
(const_string "archs4x")
62+
- (ior (symbol_ref "arc_tune == TUNE_ARCHS4XD")
63+
- (symbol_ref "arc_tune == TUNE_ARCHS4XD_SLOW"))
64+
+ (ior (symbol_ref "arc_tune == ARC_TUNE_ARCHS4XD")
65+
+ (symbol_ref "arc_tune == ARC_TUNE_ARCHS4XD_SLOW"))
66+
(const_string "archs4xd")]
67+
(const_string "none"))))
68+
69+
@@ -647,10 +645,10 @@ core_3, archs4x, archs4xd, archs4xd_slow"
70+
71+
(define_attr "tune_dspmpy" "none, slow, fast"
72+
(const
73+
- (cond [(ior (symbol_ref "arc_tune == TUNE_ARCHS4X")
74+
- (symbol_ref "arc_tune == TUNE_ARCHS4XD"))
75+
+ (cond [(ior (symbol_ref "arc_tune == ARC_TUNE_ARCHS4X")
76+
+ (symbol_ref "arc_tune == ARC_TUNE_ARCHS4XD"))
77+
(const_string "fast")
78+
- (symbol_ref "arc_tune == TUNE_ARCHS4XD_SLOW")
79+
+ (symbol_ref "arc_tune == ARC_TUNE_ARCHS4XD_SLOW")
80+
(const_string "slow")]
81+
(const_string "none"))))
82+
83+
--
84+
2.16.2
85+
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
From ad177abf331128501b92e946e532ac0361321628 Mon Sep 17 00:00:00 2001
2+
From: Claudiu Zissulescu <[email protected]>
3+
Date: Tue, 2 Apr 2019 16:43:15 +0300
4+
Subject: [PATCH 4/7] [FIX][MNL] Don't throw errors when compiling for xarch
5+
6+
---
7+
gcc/gimple-ssa-store-merging.c | 4 ++++
8+
1 file changed, 4 insertions(+)
9+
10+
diff --git a/gcc/gimple-ssa-store-merging.c b/gcc/gimple-ssa-store-merging.c
11+
index 9002bfbbad0..dbcd78ed90a 100644
12+
--- a/gcc/gimple-ssa-store-merging.c
13+
+++ b/gcc/gimple-ssa-store-merging.c
14+
@@ -161,7 +161,11 @@
15+
#include "selftest.h"
16+
17+
/* The maximum size (in bits) of the stores this pass should generate. */
18+
+#ifdef TARGET_LL64
19+
#define MAX_STORE_BITSIZE (TARGET_LL64 ? 2 * BITS_PER_WORD : BITS_PER_WORD)
20+
+#else
21+
+#define MAX_STORE_BITSIZE (BITS_PER_WORD)
22+
+#endif
23+
#define MAX_STORE_BYTES (MAX_STORE_BITSIZE / BITS_PER_UNIT)
24+
25+
/* Limit to bound the number of aliasing checks for loads with the same
26+
--
27+
2.16.2
28+

0 commit comments

Comments
 (0)