diff options
Diffstat (limited to 'meta-xilinx-bsp/recipes-microblaze/gcc/gcc-7/0003-microblaze-sync.md-Correct-behaviour-and-define-side.patch')
-rw-r--r-- | meta-xilinx-bsp/recipes-microblaze/gcc/gcc-7/0003-microblaze-sync.md-Correct-behaviour-and-define-side.patch | 76 |
1 files changed, 0 insertions, 76 deletions
diff --git a/meta-xilinx-bsp/recipes-microblaze/gcc/gcc-7/0003-microblaze-sync.md-Correct-behaviour-and-define-side.patch b/meta-xilinx-bsp/recipes-microblaze/gcc/gcc-7/0003-microblaze-sync.md-Correct-behaviour-and-define-side.patch deleted file mode 100644 index 9336291b..00000000 --- a/meta-xilinx-bsp/recipes-microblaze/gcc/gcc-7/0003-microblaze-sync.md-Correct-behaviour-and-define-side.patch +++ /dev/null | |||
@@ -1,76 +0,0 @@ | |||
1 | From 6c7a10a9e077d0221cc9a6c5f5a6365815c1dca4 Mon Sep 17 00:00:00 2001 | ||
2 | From: Nathan Rossi <nathan@nathanrossi.com> | ||
3 | Date: Mon, 12 Jun 2017 00:28:42 +1000 | ||
4 | Subject: [PATCH 3/4] microblaze/sync.md: Correct behaviour and define | ||
5 | side-effects | ||
6 | |||
7 | This change corrects the behaviour with regards to the bool output. | ||
8 | Previously the definition would set the bool operand to true (non-zero) | ||
9 | on failure, specifically at the 'cmp' against the expected operand which | ||
10 | would be set non-zero when the memory != expected value. Instead of | ||
11 | using the bool operand as the compare result use the clobbered %8 | ||
12 | operand for temporary comparison result and set the bool operand at the | ||
13 | end of the definition to true (in this case the immediate value of 1). | ||
14 | Also to ensure that the bool operand is 0 in all other cases the first | ||
15 | instruction which is intended as a clear of the carry bit is reused to | ||
16 | set the bool operand to 0 at the same time as clearing the carry bit. | ||
17 | And finally the jump offsets were updated | ||
18 | |||
19 | Additional to the behaviour change this change defines the side-effects | ||
20 | of the atomic_compare_and_swap. Specifically the side effects where the | ||
21 | bool and val operands are modified/set based on the value of the memory | ||
22 | content. This prevents certain optimization behaviour from incorrectly | ||
23 | optimizing away code. An example of this is the snippet below, where in | ||
24 | certain cases the comparison is optimized away entirely. | ||
25 | |||
26 | mem = 2; | ||
27 | if (atomic_compare_and_swap(&mem, ...) == 2) | ||
28 | ... | ||
29 | |||
30 | Signed-off-by: Nathan Rossi <nathan@nathanrossi.com> | ||
31 | Upstream-Status: Unsubmitted | ||
32 | --- | ||
33 | gcc/config/microblaze/sync.md | 14 ++++++++------ | ||
34 | 1 file changed, 8 insertions(+), 6 deletions(-) | ||
35 | |||
36 | diff --git a/gcc/config/microblaze/sync.md b/gcc/config/microblaze/sync.md | ||
37 | index 8125bd8d63..605a9a969e 100644 | ||
38 | --- a/gcc/config/microblaze/sync.md | ||
39 | +++ b/gcc/config/microblaze/sync.md | ||
40 | @@ -18,9 +18,10 @@ | ||
41 | ;; <http://www.gnu.org/licenses/>. | ||
42 | |||
43 | (define_insn "atomic_compare_and_swapsi" | ||
44 | - [(match_operand:SI 0 "register_operand" "=&d") ;; bool output | ||
45 | - (match_operand:SI 1 "register_operand" "=&d") ;; val output | ||
46 | - (match_operand:SI 2 "nonimmediate_operand" "+Q") ;; memory | ||
47 | + [(set (match_operand:SI 0 "register_operand" "=&d") ;; bool output | ||
48 | + (match_operand:SI 2 "nonimmediate_operand" "+Q")) ;; memory | ||
49 | + (set (match_operand:SI 1 "register_operand" "=&d") ;; val output | ||
50 | + (match_dup 2)) | ||
51 | (match_operand:SI 3 "register_operand" "d") ;; expected value | ||
52 | (match_operand:SI 4 "register_operand" "d") ;; desired value | ||
53 | (match_operand:SI 5 "const_int_operand" "") ;; is_weak | ||
54 | @@ -29,15 +30,16 @@ | ||
55 | (clobber (match_scratch:SI 8 "=&d"))] | ||
56 | "" | ||
57 | { | ||
58 | - output_asm_insn ("addc \tr0,r0,r0", operands); | ||
59 | + output_asm_insn ("add \t%0,r0,r0", operands); | ||
60 | output_asm_insn ("lwx \t%1,%y2,r0", operands); | ||
61 | output_asm_insn ("addic\t%8,r0,0", operands); | ||
62 | output_asm_insn ("bnei \t%8,.-8", operands); | ||
63 | - output_asm_insn ("cmp \t%0,%1,%3", operands); | ||
64 | - output_asm_insn ("bnei \t%0,.+16", operands); | ||
65 | + output_asm_insn ("cmp \t%8,%1,%3", operands); | ||
66 | + output_asm_insn ("bnei \t%8,.+20", operands); | ||
67 | output_asm_insn ("swx \t%4,%y2,r0", operands); | ||
68 | output_asm_insn ("addic\t%8,r0,0", operands); | ||
69 | output_asm_insn ("bnei \t%8,.-28", operands); | ||
70 | + output_asm_insn ("addi \t%0,r0,1", operands); | ||
71 | return ""; | ||
72 | } | ||
73 | ) | ||
74 | -- | ||
75 | 2.11.0 | ||
76 | |||