From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13697 invoked by alias); 21 Nov 2013 07:24:20 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 13685 invoked by uid 89); 21 Nov 2013 07:24:19 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: Yes, score=5.1 required=5.0 tests=AWL,BAYES_40,RDNS_NONE,SPF_PASS autolearn=no version=3.3.2 X-HELO: fencepost.gnu.org Received: from Unknown (HELO fencepost.gnu.org) (208.118.235.10) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Thu, 21 Nov 2013 07:24:18 +0000 Received: from ppp91-77-168-41.pppoe.mtu-net.ru ([91.77.168.41]:15080 helo=[192.168.1.34]) by fencepost.gnu.org with esmtpa (Exim 4.71) (envelope-from ) id 1VjOcU-0005Lx-G4 for gcc-help@gcc.gnu.org; Thu, 21 Nov 2013 02:24:10 -0500 Subject: how to disable optimization for particular assignment statements? From: Andrew Makhorin To: gcc-help@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" Date: Thu, 21 Nov 2013 08:22:00 -0000 Message-ID: <1385018681.2093.3.camel@corvax> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2013-11/txt/msg00161.txt.bz2 Hello, I have a C code like this: int foo(void) { int phase; . . . phase = 1; phase = 2; phase = 3; . . . } In case of -O0 gcc generates machine instructions for every assignment 'phase = ...'. But in case of -O2 gcc does not generate instructions for some assigments. Of course, this is correct. However, is there any way to tell gcc that 'phase' object is inspected by another thread, so it should not remove such statements? Thank you, Andrew Makhorin