summaryrefslogtreecommitdiffstats
path: root/test/Transforms/SROA/phi-and-select.ll
diff options
context:
space:
mode:
Diffstat (limited to 'test/Transforms/SROA/phi-and-select.ll')
-rw-r--r--test/Transforms/SROA/phi-and-select.ll34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/Transforms/SROA/phi-and-select.ll b/test/Transforms/SROA/phi-and-select.ll
index 8d82964..946bc40 100644
--- a/test/Transforms/SROA/phi-and-select.ll
+++ b/test/Transforms/SROA/phi-and-select.ll
@@ -501,3 +501,37 @@ end:
; CHECK-NOT: load
; CHECK: ret float %[[phi]]
}
+
+%struct.S = type { i32 }
+
+; Verifies we fixed PR20822. We have a foldable PHI feeding a speculatable PHI
+; which requires the rewriting of the speculated PHI to handle insertion
+; when the incoming pointer is itself from a PHI node. We would previously
+; insert a bitcast instruction *before* a PHI, producing an invalid module;
+; make sure we insert *after* the first non-PHI instruction.
+define void @PR20822() {
+; CHECK-LABEL: @PR20822(
+entry:
+ %f = alloca %struct.S, align 4
+; CHECK: %[[alloca:.*]] = alloca
+; CHECK: %[[cast:.*]] = bitcast i32* %[[alloca]] to %struct.S*
+ br i1 undef, label %if.end, label %for.cond
+
+for.cond: ; preds = %for.cond, %entry
+ br label %if.end
+
+if.end: ; preds = %for.cond, %entry
+ %f2 = phi %struct.S* [ %f, %entry ], [ %f, %for.cond ]
+; CHECK: phi {{.*}} %[[cast]]
+; CHECK: phi i32
+ phi i32 [ undef, %entry ], [ undef, %for.cond ]
+ br i1 undef, label %if.then5, label %if.then2
+
+if.then2: ; preds = %if.end
+ br label %if.then5
+
+if.then5: ; preds = %if.then2, %if.end
+ %f1 = phi %struct.S* [ undef, %if.then2 ], [ %f2, %if.end ]
+ store %struct.S undef, %struct.S* %f1, align 4
+ ret void
+}
OpenPOWER on IntegriCloud