[PATCH] D37619: [LV] Fix PR34523 - avoid generating redundant selects

Phabricator via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 12 23:30:13 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL313119: [LV] Fix PR34523 - avoid generating redundant selects (authored by ayalz).

Changed prior to commit:
  https://reviews.llvm.org/D37619?vs=114335&id=114976#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D37619

Files:
  llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp
  llvm/trunk/test/Transforms/LoopVectorize/if-conversion.ll


Index: llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp
===================================================================
--- llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -4526,10 +4526,10 @@
 
       for (unsigned Part = 0; Part < UF; ++Part) {
         Value *In0 = getOrCreateVectorValue(P->getIncomingValue(In), Part);
-        // We might have single edge PHIs (blocks) - use an identity
-        // 'select' for the first PHI operand.
+        assert((Cond[Part] || NumIncoming == 1) &&
+               "Multiple predecessors with one predecessor having a full mask");
         if (In == 0)
-          Entry[Part] = Builder.CreateSelect(Cond[Part], In0, In0);
+          Entry[Part] = In0; // Initialize with the first incoming value.
         else
           // Select between the current value and the previous incoming edge
           // based on the incoming mask.
Index: llvm/trunk/test/Transforms/LoopVectorize/if-conversion.ll
===================================================================
--- llvm/trunk/test/Transforms/LoopVectorize/if-conversion.ll
+++ llvm/trunk/test/Transforms/LoopVectorize/if-conversion.ll
@@ -168,3 +168,30 @@
 for.end:
   ret i32 %or
 }
+
+; Handle PHI with single incoming value having a full mask.
+; PR34523
+
+; CHECK-LABEL: PR34523
+; CHECK: vector.body
+
+define void @PR34523() {
+bb1:
+  br label %bb2
+
+bb2:                                             ; preds = %bb4, %bb1
+  %i = phi i16 [ undef, %bb1 ], [ %_tmp2, %bb4 ]
+  br label %bb3
+
+bb3:                                             ; preds = %bb2
+  %_tmp1 = phi [1 x [1 x i32]]* [ undef, %bb2 ]
+  br label %bb4
+
+bb4:                                             ; preds = %bb3
+  %_tmp2 = add i16 %i, 1
+  %_tmp3 = icmp slt i16 %_tmp2, 2
+  br i1 %_tmp3, label %bb2, label %bb5
+
+bb5:                                             ; preds = %bb4
+  unreachable
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37619.114976.patch
Type: text/x-patch
Size: 1957 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170913/9e1ae87e/attachment.bin>


More information about the llvm-commits mailing list