当 GCC 进行快速优化时保持逻辑表达式的优先级
我有一个 FreeRTOS 任务,它使用任务通知在调用函数和任务本身之间发出信号。然而,该任务也可以通过标志 dataWaiting 来“解锁”。
/* Make this function not optimized to maintain precedence of logical operation */
#pragma GCC push_options
#pragma GCC optimize ("O0")
void printTask(void * argument)
{
uart1Busy = false;
int kItr;
char chr[1];
while(1)
{
/* If data is waiting then dive straight in, otherwise wait for a notification
* from the printfdma function.
*/
if((dataWaiting || ulTaskNotifyTake(pdTRUE, portMAX_DELAY)))
{
dataWaiting = false;
如果我允许 Ofast 优化,编译器会重新排序 if 语句,以便该函数永远不会“解锁”。为了解决这个问题,我做了一个 pragma push “O0 来防止优化,但这必须应用于整个有谁
知道如何“强制”逻辑表达式的顺序以遵守Ofast 的优化?
I have a FreeRTOS task that uses task notification to signal between a calling function and the task itself. However the task can also be "unblocked" by a flag dataWaiting.
/* Make this function not optimized to maintain precedence of logical operation */
#pragma GCC push_options
#pragma GCC optimize ("O0")
void printTask(void * argument)
{
uart1Busy = false;
int kItr;
char chr[1];
while(1)
{
/* If data is waiting then dive straight in, otherwise wait for a notification
* from the printfdma function.
*/
if((dataWaiting || ulTaskNotifyTake(pdTRUE, portMAX_DELAY)))
{
dataWaiting = false;
If I allow the Ofast optimization the compiler reorders the if statement such that the function never "unblocks" To fix this I did a pragma push "O0 to prevent optimization, however this has to be applied across the whole task.
Does anyone know how you can "force" the order of the logical expression to be honored with optimization made Ofast?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论