[rtems commit] score: Avoid superfluous loads

Joel Sherrill Joel.Sherrill at OARcorp.com
Thu Nov 22 16:00:38 UTC 2012


Is this working around poor optimization?

Should we ban increment/decrement on memory?

Sebastian Huber <sebh at rtems.org> wrote:


Module:    rtems
Branch:    master
Commit:    67a9159e57649823792c8686718a7abac066cb0b
Changeset: http://git.rtems.org/rtems/commit/?id=67a9159e57649823792c8686718a7abac066cb0b

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Thu Nov 22 12:40:33 2012 +0100

score: Avoid superfluous loads

---

 cpukit/score/inline/rtems/score/thread.inl |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/cpukit/score/inline/rtems/score/thread.inl b/cpukit/score/inline/rtems/score/thread.inl
index b280638..272c14f 100644
--- a/cpukit/score/inline/rtems/score/thread.inl
+++ b/cpukit/score/inline/rtems/score/thread.inl
@@ -76,8 +76,12 @@
    */
   RTEMS_INLINE_ROUTINE uint32_t _Thread_Dispatch_increment_disable_level(void)
   {
-    _Thread_Dispatch_disable_level++;
-    return _Thread_Dispatch_disable_level;
+    uint32_t level = _Thread_Dispatch_disable_level;
+
+    ++level;
+    _Thread_Dispatch_disable_level = level;
+
+    return level;
   }

   /** @brief _Thread_Dispatch_decrement_disable_level
@@ -86,8 +90,12 @@
    */
   RTEMS_INLINE_ROUTINE uint32_t _Thread_Dispatch_decrement_disable_level(void)
   {
-    _Thread_Dispatch_disable_level--;
-    return _Thread_Dispatch_disable_level;
+    uint32_t level = _Thread_Dispatch_disable_level;
+
+    --level;
+    _Thread_Dispatch_disable_level = level;
+
+    return level;
   }

   /** @brief _Thread_Dispatch_initialization

_______________________________________________
rtems-vc mailing list
rtems-vc at rtems.org
http://www.rtems.org/mailman/listinfo/rtems-vc




More information about the devel mailing list