[llvm] r321515 - [InstCombine] Check for isa<Instruction> before using cast<>
David Blaikie via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 2 08:10:38 PST 2018
prefer dyn_cast over isa+cast (to avoid the redundant checking)
On Thu, Dec 28, 2017 at 1:36 AM Simon Pilgrim via llvm-commits <
llvm-commits at lists.llvm.org> wrote:
> Author: rksimon
> Date: Thu Dec 28 01:35:35 2017
> New Revision: 321515
>
> URL: http://llvm.org/viewvc/llvm-project?rev=321515&view=rev
> Log:
> [InstCombine] Check for isa<Instruction> before using cast<>
>
> Protects against casts from constexpr etc.
>
> Reduced from oss-fuzz #4788 test case
>
> Modified:
> llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp
> llvm/trunk/test/Transforms/InstCombine/X86/X86FsubCmpCombine.ll
>
> Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp?rev=321515&r1=321514&r2=321515&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp (original)
> +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp Thu Dec 28
> 01:35:35 2017
> @@ -2376,7 +2376,7 @@ Instruction *InstCombiner::visitCallInst
> // The compare intrinsic uses the above assumptions and therefore
> // doesn't require additional flags.
> if ((match(Arg0, m_OneUse(m_FSub(m_Value(A), m_Value(B)))) &&
> - match(Arg1, m_Zero()) &&
> + match(Arg1, m_Zero()) && isa<Instruction>(Arg0) &&
> cast<Instruction>(Arg0)->getFastMathFlags().noInfs())) {
> if (Arg0IsZero)
> std::swap(A, B);
>
> Modified: llvm/trunk/test/Transforms/InstCombine/X86/X86FsubCmpCombine.ll
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/X86/X86FsubCmpCombine.ll?rev=321515&r1=321514&r2=321515&view=diff
>
> ==============================================================================
> --- llvm/trunk/test/Transforms/InstCombine/X86/X86FsubCmpCombine.ll
> (original)
> +++ llvm/trunk/test/Transforms/InstCombine/X86/X86FsubCmpCombine.ll Thu
> Dec 28 01:35:35 2017
> @@ -122,6 +122,19 @@ entry:
> }
>
>
> +define i8 @sub_compare_folding_swapPD256_undef(<4 x double> %a, <4 x
> double> %b) {
> +; CHECK-LABEL: @sub_compare_folding_swapPD256_undef(
> +; CHECK-NEXT: entry:
> +; CHECK-NEXT: [[TMP:%.*]] = tail call i8
> @llvm.x86.avx512.mask.cmp.pd.256(<4 x double> fsub (<4 x double> undef, <4
> x double> undef), <4 x double> zeroinitializer, i32 5, i8 -1)
> +; CHECK-NEXT: ret i8 [[TMP]]
> +;
> +entry:
> + %sub.i1 = fsub ninf <4 x double> undef, undef
> + %tmp = tail call i8 @llvm.x86.avx512.mask.cmp.pd.256(<4 x double>
> %sub.i1, <4 x double> zeroinitializer, i32 5, i8 -1)
> + ret i8 %tmp
> +}
> +
> +
> define i8 @sub_compare_folding_swapPD512(<8 x double> %a, <8 x double>
> %b){
> ; CHECK-LABEL: @sub_compare_folding_swapPD512(
> ; CHECK-NEXT: entry:
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180102/603fdd18/attachment.html>
More information about the llvm-commits
mailing list