[llvm] r262907 - Fix evaluation order. Spotted by Alexander Riccio!

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 7 20:57:20 PST 2016


Perhaps just casting the right to int explicitly would suffice for
readability? Not sure - just a thought. Up to you.

On Mon, Mar 7, 2016 at 8:46 PM, Peter Collingbourne <peter at pcc.me.uk> wrote:

> Yes, it has the same semantics as that. I think the code is a little
> easier to understand the way I wrote it though, as the intent is to compare
> the lhs against one of two numbers (it just so happens that the numbers are
> 1 and 0).
>
> Peter
>
> On Mon, Mar 7, 2016 at 8:38 PM, David Blaikie <dblaikie at gmail.com> wrote:
>
>> Does this demonstrate some missing test coverage?
>>
>> Or does this code have the same semantics either way (& possibly the same
>> semantics as just "if (Target.RetVal == IsOne)"?)
>>
>> On Mon, Mar 7, 2016 at 7:50 PM, Peter Collingbourne via llvm-commits <
>> llvm-commits at lists.llvm.org> wrote:
>>
>>> Author: pcc
>>> Date: Mon Mar  7 21:50:36 2016
>>> New Revision: 262907
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=262907&view=rev
>>> Log:
>>> Fix evaluation order. Spotted by Alexander Riccio!
>>>
>>> Modified:
>>>     llvm/trunk/lib/Transforms/IPO/WholeProgramDevirt.cpp
>>>
>>> Modified: llvm/trunk/lib/Transforms/IPO/WholeProgramDevirt.cpp
>>> URL:
>>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/WholeProgramDevirt.cpp?rev=262907&r1=262906&r2=262907&view=diff
>>>
>>> ==============================================================================
>>> --- llvm/trunk/lib/Transforms/IPO/WholeProgramDevirt.cpp (original)
>>> +++ llvm/trunk/lib/Transforms/IPO/WholeProgramDevirt.cpp Mon Mar  7
>>> 21:50:36 2016
>>> @@ -459,7 +459,7 @@ bool DevirtModule::tryUniqueRetValOpt(
>>>    auto tryUniqueRetValOptFor = [&](bool IsOne) {
>>>      const BitSetInfo *UniqueBitSet = 0;
>>>      for (const VirtualCallTarget &Target : TargetsForSlot) {
>>> -      if (Target.RetVal == IsOne ? 1 : 0) {
>>> +      if (Target.RetVal == (IsOne ? 1 : 0)) {
>>>          if (UniqueBitSet)
>>>            return false;
>>>          UniqueBitSet = Target.BS;
>>>
>>>
>>> _______________________________________________
>>> llvm-commits mailing list
>>> llvm-commits at lists.llvm.org
>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>>>
>>
>>
>
>
> --
> --
> Peter
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160307/6bde5d4f/attachment.html>


More information about the llvm-commits mailing list