<div dir="ltr">This logic should probably be in llvm::ConstantFoldCall</div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jan 23, 2017 at 4:07 AM, Simon Pilgrim via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: rksimon<br>
Date: Mon Jan 23 06:07:32 2017<br>
New Revision: 292784<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=292784&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=292784&view=rev</a><br>
Log:<br>
[InstCombine][X86] MULDQ/MULUDQ undef -> zero<br>
<br>
Match generic mul behaviour so that <X x i64> multiply and muldq/muludq pattern act the same<br>
<br>
Modified:<br>
llvm/trunk/lib/Transforms/<wbr>InstCombine/InstCombineCalls.<wbr>cpp<br>
llvm/trunk/test/Transforms/<wbr>InstCombine/x86-muldq.ll<br>
<br>
Modified: llvm/trunk/lib/Transforms/<wbr>InstCombine/InstCombineCalls.<wbr>cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp?rev=292784&r1=292783&r2=292784&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/<wbr>Transforms/InstCombine/<wbr>InstCombineCalls.cpp?rev=<wbr>292784&r1=292783&r2=292784&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/Transforms/<wbr>InstCombine/InstCombineCalls.<wbr>cpp (original)<br>
+++ llvm/trunk/lib/Transforms/<wbr>InstCombine/InstCombineCalls.<wbr>cpp Mon Jan 23 06:07:32 2017<br>
@@ -515,9 +515,9 @@ static Value *simplifyX86muldq(const Int<br>
Value *Arg1 = II.getArgOperand(1);<br>
Type *ResTy = II.getType();<br>
<br>
- // muldq/muludq(undef, undef) -> undef<br>
+ // muldq/muludq(undef, undef) -> zero (matches generic mul behavior)<br>
if (isa<UndefValue>(Arg0) && isa<UndefValue>(Arg1))<br>
- return UndefValue::get(ResTy);<br>
+ return ConstantAggregateZero::get(<wbr>ResTy);<br>
<br>
return nullptr;<br>
}<br>
<br>
Modified: llvm/trunk/test/Transforms/<wbr>InstCombine/x86-muldq.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/x86-muldq.ll?rev=292784&r1=292783&r2=292784&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/test/<wbr>Transforms/InstCombine/x86-<wbr>muldq.ll?rev=292784&r1=292783&<wbr>r2=292784&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/test/Transforms/<wbr>InstCombine/x86-muldq.ll (original)<br>
+++ llvm/trunk/test/Transforms/<wbr>InstCombine/x86-muldq.ll Mon Jan 23 06:07:32 2017<br>
@@ -7,7 +7,7 @@<br>
<br>
define <2 x i64> @undef_pmuludq_128(<4 x i32> %a0, <4 x i32> %a1) {<br>
; CHECK-LABEL: @undef_pmuludq_128(<br>
-; CHECK-NEXT: ret <2 x i64> undef<br>
+; CHECK-NEXT: ret <2 x i64> zeroinitializer<br>
;<br>
%1 = call <2 x i64> @llvm.x86.sse2.pmulu.dq(<4 x i32> undef, <4 x i32> undef)<br>
ret <2 x i64> %1<br>
@@ -15,7 +15,7 @@ define <2 x i64> @undef_pmuludq_128(<4 x<br>
<br>
define <4 x i64> @undef_pmuludq_256(<8 x i32> %a0, <8 x i32> %a1) {<br>
; CHECK-LABEL: @undef_pmuludq_256(<br>
-; CHECK-NEXT: ret <4 x i64> undef<br>
+; CHECK-NEXT: ret <4 x i64> zeroinitializer<br>
;<br>
%1 = call <4 x i64> @llvm.x86.avx2.pmulu.dq(<8 x i32> undef, <8 x i32> undef)<br>
ret <4 x i64> %1<br>
@@ -23,7 +23,7 @@ define <4 x i64> @undef_pmuludq_256(<8 x<br>
<br>
define <8 x i64> @undef_pmuludq_512(<16 x i32> %a0, <16 x i32> %a1) {<br>
; CHECK-LABEL: @undef_pmuludq_512(<br>
-; CHECK-NEXT: ret <8 x i64> undef<br>
+; CHECK-NEXT: ret <8 x i64> zeroinitializer<br>
;<br>
%1 = call <8 x i64> @llvm.x86.avx512.pmulu.dq.512(<wbr><16 x i32> undef, <16 x i32> undef)<br>
ret <8 x i64> %1<br>
@@ -31,7 +31,7 @@ define <8 x i64> @undef_pmuludq_512(<16<br>
<br>
define <2 x i64> @undef_pmuldq_128(<4 x i32> %a0, <4 x i32> %a1) {<br>
; CHECK-LABEL: @undef_pmuldq_128(<br>
-; CHECK-NEXT: ret <2 x i64> undef<br>
+; CHECK-NEXT: ret <2 x i64> zeroinitializer<br>
;<br>
%1 = call <2 x i64> @llvm.x86.sse41.pmuldq(<4 x i32> undef, <4 x i32> undef)<br>
ret <2 x i64> %1<br>
@@ -39,7 +39,7 @@ define <2 x i64> @undef_pmuldq_128(<4 x<br>
<br>
define <4 x i64> @undef_pmuldq_256(<8 x i32> %a0, <8 x i32> %a1) {<br>
; CHECK-LABEL: @undef_pmuldq_256(<br>
-; CHECK-NEXT: ret <4 x i64> undef<br>
+; CHECK-NEXT: ret <4 x i64> zeroinitializer<br>
;<br>
%1 = call <4 x i64> @llvm.x86.avx2.pmul.dq(<8 x i32> undef, <8 x i32> undef)<br>
ret <4 x i64> %1<br>
@@ -47,7 +47,7 @@ define <4 x i64> @undef_pmuldq_256(<8 x<br>
<br>
define <8 x i64> @undef_pmuldq_512(<16 x i32> %a0, <16 x i32> %a1) {<br>
; CHECK-LABEL: @undef_pmuldq_512(<br>
-; CHECK-NEXT: ret <8 x i64> undef<br>
+; CHECK-NEXT: ret <8 x i64> zeroinitializer<br>
;<br>
%1 = call <8 x i64> @llvm.x86.avx512.pmul.dq.512(<<wbr>16 x i32> undef, <16 x i32> undef)<br>
ret <8 x i64> %1<br>
<br>
<br>
______________________________<wbr>_________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>