<div dir="ltr"><div>Sorry, I forgot to mention I committed this on behalf of the author of the corresponding code patch (under review at D52548):</div><div>@sheredom (Neil Henning)</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr">On Wed, Sep 26, 2018 at 2:32 PM Sanjay Patel via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: spatel<br>
Date: Wed Sep 26 13:30:47 2018<br>
New Revision: 343140<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=343140&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=343140&view=rev</a><br>
Log:<br>
[InstCombine] add tests that show undef propagation failures from D52548; NFC<br>
<br>
Differential Revision: <a href="https://reviews.llvm.org/D52556" rel="noreferrer" target="_blank">https://reviews.llvm.org/D52556</a><br>
<br>
Added:<br>
    llvm/trunk/test/Transforms/InstCombine/stop_bad_undef_propagation.ll<br>
<br>
Added: llvm/trunk/test/Transforms/InstCombine/stop_bad_undef_propagation.ll<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/stop_bad_undef_propagation.ll?rev=343140&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/stop_bad_undef_propagation.ll?rev=343140&view=auto</a><br>
==============================================================================<br>
--- llvm/trunk/test/Transforms/InstCombine/stop_bad_undef_propagation.ll (added)<br>
+++ llvm/trunk/test/Transforms/InstCombine/stop_bad_undef_propagation.ll Wed Sep 26 13:30:47 2018<br>
@@ -0,0 +1,200 @@<br>
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py<br>
+; RUN: opt < %s -instcombine -S | FileCheck %s<br>
+<br>
+; For each of the div/rem integer instructions we test 3 different variants for<br>
+; how an undef value could be back propagated:<br>
+; 0) back propagation because of an undef shuffle vector mask<br>
+; 1) back propagation because of an undef value selected from RHS<br>
+; 2) back propagation because of an undef value selected from LHS<br>
+<br>
+define <3 x float> @udiv0(<3 x float> %x, i32 %y, i32 %z) {<br>
+; CHECK-LABEL: @udiv0(<br>
+; CHECK-NEXT:    [[T5:%.*]] = shufflevector <3 x float> [[X:%.*]], <3 x float> <float 0.000000e+00, float 0.000000e+00, float undef>, <3 x i32> <i32 0, i32 3, i32 4><br>
+; CHECK-NEXT:    [[T6:%.*]] = fmul <3 x float> [[T5]], [[X]]<br>
+; CHECK-NEXT:    ret <3 x float> [[T6]]<br>
+;<br>
+  %t0 = insertelement <2 x i32> undef, i32 %y, i32 0<br>
+  %t1 = insertelement <2 x i32> %t0, i32 %z, i32 1<br>
+  %t2 = udiv <2 x i32> %t1, <i32 255, i32 255><br>
+  %t3 = uitofp <2 x i32> %t2 to <2 x float><br>
+  %t4 = shufflevector <2 x float> %t3, <2 x float> undef, <3 x i32> <i32 0, i32 1, i32 undef><br>
+  %t5 = shufflevector <3 x float> %x, <3 x float> %t4, <3 x i32> <i32 0, i32 3, i32 4><br>
+  %t6 = fmul <3 x float> %x, %t5<br>
+  ret <3 x float> %t6<br>
+}<br>
+<br>
+define <3 x float> @udiv1(<3 x float> %x, i32 %y, i32 %z) {<br>
+; CHECK-LABEL: @udiv1(<br>
+; CHECK-NEXT:    [[T5:%.*]] = shufflevector <3 x float> [[X:%.*]], <3 x float> <float 0.000000e+00, float 0.000000e+00, float undef>, <3 x i32> <i32 0, i32 3, i32 4><br>
+; CHECK-NEXT:    [[T6:%.*]] = fmul <3 x float> [[T5]], [[X]]<br>
+; CHECK-NEXT:    ret <3 x float> [[T6]]<br>
+;<br>
+  %t0 = insertelement <2 x i32> undef, i32 %y, i32 0<br>
+  %t1 = insertelement <2 x i32> %t0, i32 %z, i32 1<br>
+  %t2 = udiv <2 x i32> %t1, <i32 255, i32 255><br>
+  %t3 = uitofp <2 x i32> %t2 to <2 x float><br>
+  %t4 = shufflevector <2 x float> %t3, <2 x float> undef, <3 x i32> <i32 0, i32 1, i32 2><br>
+  %t5 = shufflevector <3 x float> %x, <3 x float> %t4, <3 x i32> <i32 0, i32 3, i32 4><br>
+  %t6 = fmul <3 x float> %x, %t5<br>
+  ret <3 x float> %t6<br>
+}<br>
+<br>
+define <3 x float> @udiv2(<3 x float> %x, i32 %y, i32 %z) {<br>
+; CHECK-LABEL: @udiv2(<br>
+; CHECK-NEXT:    [[T5:%.*]] = shufflevector <3 x float> [[X:%.*]], <3 x float> <float 0.000000e+00, float 0.000000e+00, float undef>, <3 x i32> <i32 0, i32 3, i32 4><br>
+; CHECK-NEXT:    [[T6:%.*]] = fmul <3 x float> [[T5]], [[X]]<br>
+; CHECK-NEXT:    ret <3 x float> [[T6]]<br>
+;<br>
+  %t0 = insertelement <2 x i32> undef, i32 %y, i32 0<br>
+  %t1 = insertelement <2 x i32> %t0, i32 %z, i32 1<br>
+  %t2 = udiv <2 x i32> %t1, <i32 255, i32 255><br>
+  %t3 = uitofp <2 x i32> %t2 to <2 x float><br>
+  %t4 = shufflevector <2 x float> undef, <2 x float> %t3, <3 x i32> <i32 2, i32 3, i32 0><br>
+  %t5 = shufflevector <3 x float> %x, <3 x float> %t4, <3 x i32> <i32 0, i32 3, i32 4><br>
+  %t6 = fmul <3 x float> %x, %t5<br>
+  ret <3 x float> %t6<br>
+}<br>
+<br>
+define <3 x float> @sdiv0(<3 x float> %x, i32 %y, i32 %z) {<br>
+; CHECK-LABEL: @sdiv0(<br>
+; CHECK-NEXT:    [[T5:%.*]] = shufflevector <3 x float> [[X:%.*]], <3 x float> <float 0.000000e+00, float 0.000000e+00, float undef>, <3 x i32> <i32 0, i32 3, i32 4><br>
+; CHECK-NEXT:    [[T6:%.*]] = fmul <3 x float> [[T5]], [[X]]<br>
+; CHECK-NEXT:    ret <3 x float> [[T6]]<br>
+;<br>
+  %t0 = insertelement <2 x i32> undef, i32 %y, i32 0<br>
+  %t1 = insertelement <2 x i32> %t0, i32 %z, i32 1<br>
+  %t2 = sdiv <2 x i32> %t1, <i32 255, i32 255><br>
+  %t3 = sitofp <2 x i32> %t2 to <2 x float><br>
+  %t4 = shufflevector <2 x float> %t3, <2 x float> undef, <3 x i32> <i32 0, i32 1, i32 undef><br>
+  %t5 = shufflevector <3 x float> %x, <3 x float> %t4, <3 x i32> <i32 0, i32 3, i32 4><br>
+  %t6 = fmul <3 x float> %x, %t5<br>
+  ret <3 x float> %t6<br>
+}<br>
+<br>
+define <3 x float> @sdiv1(<3 x float> %x, i32 %y, i32 %z) {<br>
+; CHECK-LABEL: @sdiv1(<br>
+; CHECK-NEXT:    [[T5:%.*]] = shufflevector <3 x float> [[X:%.*]], <3 x float> <float 0.000000e+00, float 0.000000e+00, float undef>, <3 x i32> <i32 0, i32 3, i32 4><br>
+; CHECK-NEXT:    [[T6:%.*]] = fmul <3 x float> [[T5]], [[X]]<br>
+; CHECK-NEXT:    ret <3 x float> [[T6]]<br>
+;<br>
+  %t0 = insertelement <2 x i32> undef, i32 %y, i32 0<br>
+  %t1 = insertelement <2 x i32> %t0, i32 %z, i32 1<br>
+  %t2 = sdiv <2 x i32> %t1, <i32 255, i32 255><br>
+  %t3 = sitofp <2 x i32> %t2 to <2 x float><br>
+  %t4 = shufflevector <2 x float> %t3, <2 x float> undef, <3 x i32> <i32 0, i32 1, i32 2><br>
+  %t5 = shufflevector <3 x float> %x, <3 x float> %t4, <3 x i32> <i32 0, i32 3, i32 4><br>
+  %t6 = fmul <3 x float> %x, %t5<br>
+  ret <3 x float> %t6<br>
+}<br>
+<br>
+define <3 x float> @sdiv2(<3 x float> %x, i32 %y, i32 %z) {<br>
+; CHECK-LABEL: @sdiv2(<br>
+; CHECK-NEXT:    [[T5:%.*]] = shufflevector <3 x float> [[X:%.*]], <3 x float> <float 0.000000e+00, float 0.000000e+00, float undef>, <3 x i32> <i32 0, i32 3, i32 4><br>
+; CHECK-NEXT:    [[T6:%.*]] = fmul <3 x float> [[T5]], [[X]]<br>
+; CHECK-NEXT:    ret <3 x float> [[T6]]<br>
+;<br>
+  %t0 = insertelement <2 x i32> undef, i32 %y, i32 0<br>
+  %t1 = insertelement <2 x i32> %t0, i32 %z, i32 1<br>
+  %t2 = sdiv <2 x i32> %t1, <i32 255, i32 255><br>
+  %t3 = sitofp <2 x i32> %t2 to <2 x float><br>
+  %t4 = shufflevector <2 x float> undef, <2 x float> %t3, <3 x i32> <i32 2, i32 3, i32 0><br>
+  %t5 = shufflevector <3 x float> %x, <3 x float> %t4, <3 x i32> <i32 0, i32 3, i32 4><br>
+  %t6 = fmul <3 x float> %x, %t5<br>
+  ret <3 x float> %t6<br>
+}<br>
+<br>
+define <3 x float> @urem0(<3 x float> %x, i32 %y, i32 %z) {<br>
+; CHECK-LABEL: @urem0(<br>
+; CHECK-NEXT:    [[T5:%.*]] = shufflevector <3 x float> [[X:%.*]], <3 x float> <float 0.000000e+00, float 0.000000e+00, float undef>, <3 x i32> <i32 0, i32 3, i32 4><br>
+; CHECK-NEXT:    [[T6:%.*]] = fmul <3 x float> [[T5]], [[X]]<br>
+; CHECK-NEXT:    ret <3 x float> [[T6]]<br>
+;<br>
+  %t0 = insertelement <2 x i32> undef, i32 %y, i32 0<br>
+  %t1 = insertelement <2 x i32> %t0, i32 %z, i32 1<br>
+  %t2 = urem <2 x i32> %t1, <i32 255, i32 255><br>
+  %t3 = uitofp <2 x i32> %t2 to <2 x float><br>
+  %t4 = shufflevector <2 x float> %t3, <2 x float> undef, <3 x i32> <i32 0, i32 1, i32 undef><br>
+  %t5 = shufflevector <3 x float> %x, <3 x float> %t4, <3 x i32> <i32 0, i32 3, i32 4><br>
+  %t6 = fmul <3 x float> %x, %t5<br>
+  ret <3 x float> %t6<br>
+}<br>
+<br>
+define <3 x float> @urem1(<3 x float> %x, i32 %y, i32 %z) {<br>
+; CHECK-LABEL: @urem1(<br>
+; CHECK-NEXT:    [[T5:%.*]] = shufflevector <3 x float> [[X:%.*]], <3 x float> <float 0.000000e+00, float 0.000000e+00, float undef>, <3 x i32> <i32 0, i32 3, i32 4><br>
+; CHECK-NEXT:    [[T6:%.*]] = fmul <3 x float> [[T5]], [[X]]<br>
+; CHECK-NEXT:    ret <3 x float> [[T6]]<br>
+;<br>
+  %t0 = insertelement <2 x i32> undef, i32 %y, i32 0<br>
+  %t1 = insertelement <2 x i32> %t0, i32 %z, i32 1<br>
+  %t2 = urem <2 x i32> %t1, <i32 255, i32 255><br>
+  %t3 = uitofp <2 x i32> %t2 to <2 x float><br>
+  %t4 = shufflevector <2 x float> %t3, <2 x float> undef, <3 x i32> <i32 0, i32 1, i32 2><br>
+  %t5 = shufflevector <3 x float> %x, <3 x float> %t4, <3 x i32> <i32 0, i32 3, i32 4><br>
+  %t6 = fmul <3 x float> %x, %t5<br>
+  ret <3 x float> %t6<br>
+}<br>
+<br>
+define <3 x float> @urem2(<3 x float> %x, i32 %y, i32 %z) {<br>
+; CHECK-LABEL: @urem2(<br>
+; CHECK-NEXT:    [[T5:%.*]] = shufflevector <3 x float> [[X:%.*]], <3 x float> <float 0.000000e+00, float 0.000000e+00, float undef>, <3 x i32> <i32 0, i32 3, i32 4><br>
+; CHECK-NEXT:    [[T6:%.*]] = fmul <3 x float> [[T5]], [[X]]<br>
+; CHECK-NEXT:    ret <3 x float> [[T6]]<br>
+;<br>
+  %t0 = insertelement <2 x i32> undef, i32 %y, i32 0<br>
+  %t1 = insertelement <2 x i32> %t0, i32 %z, i32 1<br>
+  %t2 = urem <2 x i32> %t1, <i32 255, i32 255><br>
+  %t3 = uitofp <2 x i32> %t2 to <2 x float><br>
+  %t4 = shufflevector <2 x float> undef, <2 x float> %t3, <3 x i32> <i32 2, i32 3, i32 0><br>
+  %t5 = shufflevector <3 x float> %x, <3 x float> %t4, <3 x i32> <i32 0, i32 3, i32 4><br>
+  %t6 = fmul <3 x float> %x, %t5<br>
+  ret <3 x float> %t6<br>
+}<br>
+<br>
+define <3 x float> @srem0(<3 x float> %x, i32 %y, i32 %z) {<br>
+; CHECK-LABEL: @srem0(<br>
+; CHECK-NEXT:    [[T5:%.*]] = shufflevector <3 x float> [[X:%.*]], <3 x float> <float 0.000000e+00, float 0.000000e+00, float undef>, <3 x i32> <i32 0, i32 3, i32 4><br>
+; CHECK-NEXT:    [[T6:%.*]] = fmul <3 x float> [[T5]], [[X]]<br>
+; CHECK-NEXT:    ret <3 x float> [[T6]]<br>
+;<br>
+  %t0 = insertelement <2 x i32> undef, i32 %y, i32 0<br>
+  %t1 = insertelement <2 x i32> %t0, i32 %z, i32 1<br>
+  %t2 = srem <2 x i32> %t1, <i32 255, i32 255><br>
+  %t3 = sitofp <2 x i32> %t2 to <2 x float><br>
+  %t4 = shufflevector <2 x float> %t3, <2 x float> undef, <3 x i32> <i32 0, i32 1, i32 undef><br>
+  %t5 = shufflevector <3 x float> %x, <3 x float> %t4, <3 x i32> <i32 0, i32 3, i32 4><br>
+  %t6 = fmul <3 x float> %x, %t5<br>
+  ret <3 x float> %t6<br>
+}<br>
+<br>
+define <3 x float> @srem1(<3 x float> %x, i32 %y, i32 %z) {<br>
+; CHECK-LABEL: @srem1(<br>
+; CHECK-NEXT:    [[T5:%.*]] = shufflevector <3 x float> [[X:%.*]], <3 x float> <float 0.000000e+00, float 0.000000e+00, float undef>, <3 x i32> <i32 0, i32 3, i32 4><br>
+; CHECK-NEXT:    [[T6:%.*]] = fmul <3 x float> [[T5]], [[X]]<br>
+; CHECK-NEXT:    ret <3 x float> [[T6]]<br>
+;<br>
+  %t0 = insertelement <2 x i32> undef, i32 %y, i32 0<br>
+  %t1 = insertelement <2 x i32> %t0, i32 %z, i32 1<br>
+  %t2 = srem <2 x i32> %t1, <i32 255, i32 255><br>
+  %t3 = sitofp <2 x i32> %t2 to <2 x float><br>
+  %t4 = shufflevector <2 x float> %t3, <2 x float> undef, <3 x i32> <i32 0, i32 1, i32 2><br>
+  %t5 = shufflevector <3 x float> %x, <3 x float> %t4, <3 x i32> <i32 0, i32 3, i32 4><br>
+  %t6 = fmul <3 x float> %x, %t5<br>
+  ret <3 x float> %t6<br>
+}<br>
+<br>
+define <3 x float> @srem2(<3 x float> %x, i32 %y, i32 %z) {<br>
+; CHECK-LABEL: @srem2(<br>
+; CHECK-NEXT:    [[T5:%.*]] = shufflevector <3 x float> [[X:%.*]], <3 x float> <float 0.000000e+00, float 0.000000e+00, float undef>, <3 x i32> <i32 0, i32 3, i32 4><br>
+; CHECK-NEXT:    [[T6:%.*]] = fmul <3 x float> [[T5]], [[X]]<br>
+; CHECK-NEXT:    ret <3 x float> [[T6]]<br>
+;<br>
+  %t0 = insertelement <2 x i32> undef, i32 %y, i32 0<br>
+  %t1 = insertelement <2 x i32> %t0, i32 %z, i32 1<br>
+  %t2 = srem <2 x i32> %t1, <i32 255, i32 255><br>
+  %t3 = sitofp <2 x i32> %t2 to <2 x float><br>
+  %t4 = shufflevector <2 x float> undef, <2 x float> %t3, <3 x i32> <i32 2, i32 3, i32 0><br>
+  %t5 = shufflevector <3 x float> %x, <3 x float> %t4, <3 x i32> <i32 0, i32 3, i32 4><br>
+  %t6 = fmul <3 x float> %x, %t5<br>
+  ret <3 x float> %t6<br>
+}<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">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/mailman/listinfo/llvm-commits</a><br>
</blockquote></div>