[llvm] r274905 - [SCCP] Fold constants as we build them whne visiting cast instructions.

Davide Italiano via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 11 11:29:15 PDT 2016


On Fri, Jul 8, 2016 at 12:37 PM, Eli Friedman <eli.friedman at gmail.com> wrote:
> On Fri, Jul 8, 2016 at 12:13 PM, Davide Italiano via llvm-commits
> <llvm-commits at lists.llvm.org> wrote:
>>
>> Author: davide
>> Date: Fri Jul  8 14:13:40 2016
>> New Revision: 274905
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=274905&view=rev
>> Log:
>> [SCCP] Fold constants as we build them whne visiting cast instructions.
>>
>> This should be slightly more efficient and could avoid spurious
>> overdefined
>> markings, as Eli pointed out.
>>
>> Differential Revision:  http://reviews.llvm.org/D22122
>>
>> Added:
>>     llvm/trunk/test/Transforms/SCCP/bitcast.ll
>> Modified:
>>     llvm/trunk/lib/Transforms/Scalar/SCCP.cpp
>>
>> Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SCCP.cpp?rev=274905&r1=274904&r2=274905&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/lib/Transforms/Scalar/SCCP.cpp (original)
>> +++ llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Fri Jul  8 14:13:40 2016
>> @@ -760,8 +760,10 @@ void SCCPSolver::visitCastInst(CastInst
>>    if (OpSt.isOverdefined())          // Inherit overdefinedness of
>> operand
>>      markOverdefined(&I);
>>    else if (OpSt.isConstant()) {
>> -    Constant *C =
>> -        ConstantExpr::getCast(I.getOpcode(), OpSt.getConstant(),
>> I.getType());
>> +    // Fold the constant as we build.
>> +    Constant *C = ConstantFoldCastOperand(
>> +        I.getOpcode(), getValueState(I.getOperand(0)).getConstant(),
>> +        I.getType(), DL);
>
>
> Maybe just use `OpSt` here instead of writing out
> `getValueState(I.getOperand(0))`?
>
> -Eli

r275084. Thanks, and sorry for not noticing it earlier.

-- 
Davide

"There are no solved problems; there are only problems that are more
or less solved" -- Henri Poincare


More information about the llvm-commits mailing list