[llvm] r299915 - [InstCombine] Support weird size element types in dyn_castNegVal.

Friedman, Eli via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 11 11:35:44 PDT 2017


On 4/10/2017 10:42 PM, Craig Topper via llvm-commits wrote:
> Author: ctopper
> Date: Tue Apr 11 00:42:47 2017
> New Revision: 299915
>
> URL: http://llvm.org/viewvc/llvm-project?rev=299915&view=rev
> Log:
> [InstCombine] Support weird size element types in dyn_castNegVal.
>
> Modified:
>      llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp
>      llvm/trunk/test/Transforms/InstCombine/2008-05-22-NegValVector.ll
>      llvm/trunk/test/Transforms/InstCombine/rem.ll
>
> Modified: llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp?rev=299915&r1=299914&r2=299915&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp (original)
> +++ llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp Tue Apr 11 00:42:47 2017
> @@ -726,6 +726,10 @@ Value *InstCombiner::dyn_castNegVal(Valu
>       if (C->getType()->getElementType()->isIntegerTy())
>         return ConstantExpr::getNeg(C);
>   
> +  if (ConstantVector *C = dyn_cast<ConstantVector>(V))
> +    if (C->getType()->getElementType()->isIntegerTy())
> +      return ConstantExpr::getNeg(C);

Do you need to check the operands of the ConstantVector here?  The 
existing code carefully avoids making new ConstantExprs.

-Eli

-- 
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project



More information about the llvm-commits mailing list