<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">I added constant folding support which currently handles the 1 undef case, but I can move it into the early out very easily.<div class=""><br class=""></div><div class="">David - I’ll investigate whether moving this to constant folding is viable.</div><div class=""><br class=""></div><div class="">Cheers, Simon.<br class=""><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 24 Jan 2017, at 02:11, Craig Topper <<a href="mailto:craig.topper@gmail.com" class="">craig.topper@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Shouldn't it be if either is undef return 0?<div class=""><br class=""></div><div class="">Generic mul does this</div><div class=""><br class=""></div><div class=""> // X * undef -> 0<br class=""></div></div><div class="gmail_extra"><br clear="all" class=""><div class=""><div class="gmail_signature" data-smartmail="gmail_signature">~Craig</div></div>
<br class=""><div class="gmail_quote">On Mon, Jan 23, 2017 at 4:07 AM, Simon Pilgrim via llvm-commits <span dir="ltr" class=""><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank" class="">llvm-commits@lists.llvm.org</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: rksimon<br class="">
Date: Mon Jan 23 06:07:32 2017<br class="">
New Revision: 292784<br class="">
<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=292784&view=rev" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-<wbr class="">project?rev=292784&view=rev</a><br class="">
Log:<br class="">
[InstCombine][X86] MULDQ/MULUDQ undef -> zero<br class="">
<br class="">
Match generic mul behaviour so that <X x i64> multiply and muldq/muludq pattern act the same<br class="">
<br class="">
Modified:<br class="">
llvm/trunk/lib/Transforms/<wbr class="">InstCombine/InstCombineCalls.<wbr class="">cpp<br class="">
llvm/trunk/test/Transforms/<wbr class="">InstCombine/x86-muldq.ll<br class="">
<br class="">
Modified: llvm/trunk/lib/Transforms/<wbr class="">InstCombine/InstCombineCalls.<wbr class="">cpp<br class="">
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" class="">http://llvm.org/viewvc/llvm-<wbr class="">project/llvm/trunk/lib/<wbr class="">Transforms/InstCombine/<wbr class="">InstCombineCalls.cpp?rev=<wbr class="">292784&r1=292783&r2=292784&<wbr class="">view=diff</a><br class="">
==============================<wbr class="">==============================<wbr class="">==================<br class="">
--- llvm/trunk/lib/Transforms/<wbr class="">InstCombine/InstCombineCalls.<wbr class="">cpp (original)<br class="">
+++ llvm/trunk/lib/Transforms/<wbr class="">InstCombine/InstCombineCalls.<wbr class="">cpp Mon Jan 23 06:07:32 2017<br class="">
@@ -515,9 +515,9 @@ static Value *simplifyX86muldq(const Int<br class="">
Value *Arg1 = II.getArgOperand(1);<br class="">
Type *ResTy = II.getType();<br class="">
<br class="">
- // muldq/muludq(undef, undef) -> undef<br class="">
+ // muldq/muludq(undef, undef) -> zero (matches generic mul behavior)<br class="">
if (isa<UndefValue>(Arg0) && isa<UndefValue>(Arg1))<br class="">
- return UndefValue::get(ResTy);<br class="">
+ return ConstantAggregateZero::get(<wbr class="">ResTy);<br class="">
<br class="">
return nullptr;<br class="">
}<br class="">
<br class="">
Modified: llvm/trunk/test/Transforms/<wbr class="">InstCombine/x86-muldq.ll<br class="">
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" class="">http://llvm.org/viewvc/llvm-<wbr class="">project/llvm/trunk/test/<wbr class="">Transforms/InstCombine/x86-<wbr class="">muldq.ll?rev=292784&r1=292783&<wbr class="">r2=292784&view=diff</a><br class="">
==============================<wbr class="">==============================<wbr class="">==================<br class="">
--- llvm/trunk/test/Transforms/<wbr class="">InstCombine/x86-muldq.ll (original)<br class="">
+++ llvm/trunk/test/Transforms/<wbr class="">InstCombine/x86-muldq.ll Mon Jan 23 06:07:32 2017<br class="">
@@ -7,7 +7,7 @@<br class="">
<br class="">
define <2 x i64> @undef_pmuludq_128(<4 x i32> %a0, <4 x i32> %a1) {<br class="">
; CHECK-LABEL: @undef_pmuludq_128(<br class="">
-; CHECK-NEXT: ret <2 x i64> undef<br class="">
+; CHECK-NEXT: ret <2 x i64> zeroinitializer<br class="">
;<br class="">
%1 = call <2 x i64> @llvm.x86.sse2.pmulu.dq(<4 x i32> undef, <4 x i32> undef)<br class="">
ret <2 x i64> %1<br class="">
@@ -15,7 +15,7 @@ define <2 x i64> @undef_pmuludq_128(<4 x<br class="">
<br class="">
define <4 x i64> @undef_pmuludq_256(<8 x i32> %a0, <8 x i32> %a1) {<br class="">
; CHECK-LABEL: @undef_pmuludq_256(<br class="">
-; CHECK-NEXT: ret <4 x i64> undef<br class="">
+; CHECK-NEXT: ret <4 x i64> zeroinitializer<br class="">
;<br class="">
%1 = call <4 x i64> @llvm.x86.avx2.pmulu.dq(<8 x i32> undef, <8 x i32> undef)<br class="">
ret <4 x i64> %1<br class="">
@@ -23,7 +23,7 @@ define <4 x i64> @undef_pmuludq_256(<8 x<br class="">
<br class="">
define <8 x i64> @undef_pmuludq_512(<16 x i32> %a0, <16 x i32> %a1) {<br class="">
; CHECK-LABEL: @undef_pmuludq_512(<br class="">
-; CHECK-NEXT: ret <8 x i64> undef<br class="">
+; CHECK-NEXT: ret <8 x i64> zeroinitializer<br class="">
;<br class="">
%1 = call <8 x i64> @llvm.x86.avx512.pmulu.dq.512(<wbr class=""><16 x i32> undef, <16 x i32> undef)<br class="">
ret <8 x i64> %1<br class="">
@@ -31,7 +31,7 @@ define <8 x i64> @undef_pmuludq_512(<16<br class="">
<br class="">
define <2 x i64> @undef_pmuldq_128(<4 x i32> %a0, <4 x i32> %a1) {<br class="">
; CHECK-LABEL: @undef_pmuldq_128(<br class="">
-; CHECK-NEXT: ret <2 x i64> undef<br class="">
+; CHECK-NEXT: ret <2 x i64> zeroinitializer<br class="">
;<br class="">
%1 = call <2 x i64> @llvm.x86.sse41.pmuldq(<4 x i32> undef, <4 x i32> undef)<br class="">
ret <2 x i64> %1<br class="">
@@ -39,7 +39,7 @@ define <2 x i64> @undef_pmuldq_128(<4 x<br class="">
<br class="">
define <4 x i64> @undef_pmuldq_256(<8 x i32> %a0, <8 x i32> %a1) {<br class="">
; CHECK-LABEL: @undef_pmuldq_256(<br class="">
-; CHECK-NEXT: ret <4 x i64> undef<br class="">
+; CHECK-NEXT: ret <4 x i64> zeroinitializer<br class="">
;<br class="">
%1 = call <4 x i64> @llvm.x86.avx2.pmul.dq(<8 x i32> undef, <8 x i32> undef)<br class="">
ret <4 x i64> %1<br class="">
@@ -47,7 +47,7 @@ define <4 x i64> @undef_pmuldq_256(<8 x<br class="">
<br class="">
define <8 x i64> @undef_pmuldq_512(<16 x i32> %a0, <16 x i32> %a1) {<br class="">
; CHECK-LABEL: @undef_pmuldq_512(<br class="">
-; CHECK-NEXT: ret <8 x i64> undef<br class="">
+; CHECK-NEXT: ret <8 x i64> zeroinitializer<br class="">
;<br class="">
%1 = call <8 x i64> @llvm.x86.avx512.pmul.dq.512(<<wbr class="">16 x i32> undef, <16 x i32> undef)<br class="">
ret <8 x i64> %1<br class="">
<br class="">
<br class="">
______________________________<wbr class="">_________________<br class="">
llvm-commits mailing list<br class="">
<a href="mailto:llvm-commits@lists.llvm.org" class="">llvm-commits@lists.llvm.org</a><br class="">
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank" class="">http://lists.llvm.org/cgi-bin/<wbr class="">mailman/listinfo/llvm-commits</a><br class="">
</blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></div></div></body></html>