相关疑难解决方法(0)

为什么条件移动不易受分支预测失败的影响?

在阅读了这篇文章后(在StackOverflow上回答)(在优化部分),我想知道为什么条件移动不容易受到分支预测失败的影响.我在一篇关于cond移动的文章中找到了(PDF由AMD提供).在那里,他们声称cond的性能优势.移动.但为什么会这样呢?我没有看到它.在评估ASM指令的时刻,前面的CMP指令的结果尚未知晓.

谢谢.

optimization performance assembly cpu-architecture branch-prediction

72
推荐指数
4
解决办法
1万
查看次数

C:使用无符号操作数的一元减运算符行为

我似乎无法在C标准中找到完全定义带有无符号操作数的一元减运算符的行为的相关部分.

2003 C++标准(是的,C++,我用几行代表)在5.3.1c7中说: The negative of an unsigned quantity is computed by subtracting its value from 2^n, where n is the number of bits in the promoted operand.

然而,1999 C标准并未包含这样一个明确的陈述,也没有明确界定一元行为 - 在6.5.3.3c1,3和6.5c4中都没有.在后者中它说Some operators (the unary operator ~, and the binary operators <<, >>, &, ^, and |, ...) ... return values that depend on the internal representations of integers, and have implementation-defined and undefined aspects for signed types.),它排除了一元减去,事情似乎仍然含糊不清.

这个早期的问题是指K&R ANSI C一书中的A.7.4.5节The negative of an unsigned quantity …

c unary-operator

33
推荐指数
3
解决办法
1万
查看次数