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

Eli Friedman via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 8 12:37:58 PDT 2016


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160708/817a95bf/attachment.html>


More information about the llvm-commits mailing list