[llvm] r292784 - [InstCombine][X86] MULDQ/MULUDQ undef -> zero
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 24 01:38:18 PST 2017
I added constant folding support which currently handles the 1 undef case, but I can move it into the early out very easily.
David - I’ll investigate whether moving this to constant folding is viable.
Cheers, Simon.
> On 24 Jan 2017, at 02:11, Craig Topper <craig.topper at gmail.com> wrote:
>
> Shouldn't it be if either is undef return 0?
>
> Generic mul does this
>
> // X * undef -> 0
>
> ~Craig
>
> On Mon, Jan 23, 2017 at 4:07 AM, Simon Pilgrim via llvm-commits <llvm-commits at lists.llvm.org <mailto:llvm-commits at lists.llvm.org>> wrote:
> Author: rksimon
> Date: Mon Jan 23 06:07:32 2017
> New Revision: 292784
>
> URL: http://llvm.org/viewvc/llvm-project?rev=292784&view=rev <http://llvm.org/viewvc/llvm-project?rev=292784&view=rev>
> Log:
> [InstCombine][X86] MULDQ/MULUDQ undef -> zero
>
> Match generic mul behaviour so that <X x i64> multiply and muldq/muludq pattern act the same
>
> Modified:
> llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp
> llvm/trunk/test/Transforms/InstCombine/x86-muldq.ll
>
> Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp?rev=292784&r1=292783&r2=292784&view=diff <http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp?rev=292784&r1=292783&r2=292784&view=diff>
> ==============================================================================
> --- llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp (original)
> +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp Mon Jan 23 06:07:32 2017
> @@ -515,9 +515,9 @@ static Value *simplifyX86muldq(const Int
> Value *Arg1 = II.getArgOperand(1);
> Type *ResTy = II.getType();
>
> - // muldq/muludq(undef, undef) -> undef
> + // muldq/muludq(undef, undef) -> zero (matches generic mul behavior)
> if (isa<UndefValue>(Arg0) && isa<UndefValue>(Arg1))
> - return UndefValue::get(ResTy);
> + return ConstantAggregateZero::get(ResTy);
>
> return nullptr;
> }
>
> Modified: llvm/trunk/test/Transforms/InstCombine/x86-muldq.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/x86-muldq.ll?rev=292784&r1=292783&r2=292784&view=diff <http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/x86-muldq.ll?rev=292784&r1=292783&r2=292784&view=diff>
> ==============================================================================
> --- llvm/trunk/test/Transforms/InstCombine/x86-muldq.ll (original)
> +++ llvm/trunk/test/Transforms/InstCombine/x86-muldq.ll Mon Jan 23 06:07:32 2017
> @@ -7,7 +7,7 @@
>
> define <2 x i64> @undef_pmuludq_128(<4 x i32> %a0, <4 x i32> %a1) {
> ; CHECK-LABEL: @undef_pmuludq_128(
> -; CHECK-NEXT: ret <2 x i64> undef
> +; CHECK-NEXT: ret <2 x i64> zeroinitializer
> ;
> %1 = call <2 x i64> @llvm.x86.sse2.pmulu.dq(<4 x i32> undef, <4 x i32> undef)
> ret <2 x i64> %1
> @@ -15,7 +15,7 @@ define <2 x i64> @undef_pmuludq_128(<4 x
>
> define <4 x i64> @undef_pmuludq_256(<8 x i32> %a0, <8 x i32> %a1) {
> ; CHECK-LABEL: @undef_pmuludq_256(
> -; CHECK-NEXT: ret <4 x i64> undef
> +; CHECK-NEXT: ret <4 x i64> zeroinitializer
> ;
> %1 = call <4 x i64> @llvm.x86.avx2.pmulu.dq(<8 x i32> undef, <8 x i32> undef)
> ret <4 x i64> %1
> @@ -23,7 +23,7 @@ define <4 x i64> @undef_pmuludq_256(<8 x
>
> define <8 x i64> @undef_pmuludq_512(<16 x i32> %a0, <16 x i32> %a1) {
> ; CHECK-LABEL: @undef_pmuludq_512(
> -; CHECK-NEXT: ret <8 x i64> undef
> +; CHECK-NEXT: ret <8 x i64> zeroinitializer
> ;
> %1 = call <8 x i64> @llvm.x86.avx512.pmulu.dq.512(<16 x i32> undef, <16 x i32> undef)
> ret <8 x i64> %1
> @@ -31,7 +31,7 @@ define <8 x i64> @undef_pmuludq_512(<16
>
> define <2 x i64> @undef_pmuldq_128(<4 x i32> %a0, <4 x i32> %a1) {
> ; CHECK-LABEL: @undef_pmuldq_128(
> -; CHECK-NEXT: ret <2 x i64> undef
> +; CHECK-NEXT: ret <2 x i64> zeroinitializer
> ;
> %1 = call <2 x i64> @llvm.x86.sse41.pmuldq(<4 x i32> undef, <4 x i32> undef)
> ret <2 x i64> %1
> @@ -39,7 +39,7 @@ define <2 x i64> @undef_pmuldq_128(<4 x
>
> define <4 x i64> @undef_pmuldq_256(<8 x i32> %a0, <8 x i32> %a1) {
> ; CHECK-LABEL: @undef_pmuldq_256(
> -; CHECK-NEXT: ret <4 x i64> undef
> +; CHECK-NEXT: ret <4 x i64> zeroinitializer
> ;
> %1 = call <4 x i64> @llvm.x86.avx2.pmul.dq(<8 x i32> undef, <8 x i32> undef)
> ret <4 x i64> %1
> @@ -47,7 +47,7 @@ define <4 x i64> @undef_pmuldq_256(<8 x
>
> define <8 x i64> @undef_pmuldq_512(<16 x i32> %a0, <16 x i32> %a1) {
> ; CHECK-LABEL: @undef_pmuldq_512(
> -; CHECK-NEXT: ret <8 x i64> undef
> +; CHECK-NEXT: ret <8 x i64> zeroinitializer
> ;
> %1 = call <8 x i64> @llvm.x86.avx512.pmul.dq.512(<16 x i32> undef, <16 x i32> undef)
> ret <8 x i64> %1
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org <mailto:llvm-commits at lists.llvm.org>
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits <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/20170124/91fb1a90/attachment.html>
More information about the llvm-commits
mailing list