summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Kruse <llvm@meinersbur.de>2017-09-07 12:15:01 +0000
committerMichael Kruse <llvm@meinersbur.de>2017-09-07 12:15:01 +0000
commit2f5cbc449a6371486982c20648975ee70894f71d (patch)
treee423960eb64316459e9d2d5469dd2669e1d6296e
parent7372d48c748711b5256d0cea95ab58810c65b1d8 (diff)
downloadbcm5719-llvm-2f5cbc449a6371486982c20648975ee70894f71d.tar.gz
bcm5719-llvm-2f5cbc449a6371486982c20648975ee70894f71d.zip
[CodeGen] Bitcast scalar writes to actual value.
The type of NewValue might change due to ScalarEvolution looking though bitcasts. The synthesized NewValue therefore becomes the type before the bitcast. llvm-svn: 312718
-rw-r--r--polly/lib/CodeGen/BlockGenerators.cpp7
-rw-r--r--polly/test/Isl/CodeGen/scev_looking_through_bitcasts.ll37
2 files changed, 44 insertions, 0 deletions
diff --git a/polly/lib/CodeGen/BlockGenerators.cpp b/polly/lib/CodeGen/BlockGenerators.cpp
index 5988fc88da0..53b6f500997 100644
--- a/polly/lib/CodeGen/BlockGenerators.cpp
+++ b/polly/lib/CodeGen/BlockGenerators.cpp
@@ -692,6 +692,13 @@ void BlockGenerator::generateScalarStores(
DT.dominates(cast<Instruction>(Address)->getParent(),
Builder.GetInsertBlock())) &&
"Domination violation");
+
+ // The new Val might have a different type than the old Val due to
+ // ScalarEvolution looking through bitcasts.
+ if (Val->getType() != Address->getType()->getPointerElementType())
+ Address = Builder.CreateBitOrPointerCast(
+ Address, Val->getType()->getPointerTo());
+
Builder.CreateStore(Val, Address);
});
diff --git a/polly/test/Isl/CodeGen/scev_looking_through_bitcasts.ll b/polly/test/Isl/CodeGen/scev_looking_through_bitcasts.ll
new file mode 100644
index 00000000000..1012e23cd3a
--- /dev/null
+++ b/polly/test/Isl/CodeGen/scev_looking_through_bitcasts.ll
@@ -0,0 +1,37 @@
+; RUN: opt %loadPolly -polly-codegen -S < %s | FileCheck %s
+;
+; Scalar write of bitcasted value. Instead of writing %b of type
+; %structty, the SCEV expression looks through the bitcast such that
+; SCEVExpander returns %add.ptr81.i of type i8* to be the new value
+; of %b.
+;
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+
+%structty = type { %structty*, %structty*, i32, [2 x i64] }
+
+define void @bitmap_set_range() {
+entry:
+ %a = ptrtoint i8* undef to i64
+ br label %cond.end32.i
+
+cond.end32.i:
+ br i1 false, label %cond.true67.i, label %cond.end73.i
+
+cond.true67.i:
+ br label %cond.end73.i
+
+cond.end73.i:
+ %add.ptr81.i = getelementptr inbounds i8, i8* null, i64 %a
+ %b = bitcast i8* %add.ptr81.i to %structty*
+ br label %bitmap_element_allocate.exit
+
+bitmap_element_allocate.exit:
+ %tobool43 = icmp eq %structty* %b, null
+ ret void
+}
+
+
+; CHECK: polly.stmt.cond.end73.i:
+; CHECK-NEXT: %0 = bitcast %structty** %b.s2a to i8**
+; CHECK-NEXT: store i8* undef, i8** %0
+; CHECK-NEXT: br label %polly.exiting
OpenPOWER on IntegriCloud