[polly] r312718 - [CodeGen] Bitcast scalar writes to actual value.
Michael Kruse via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 7 05:15:01 PDT 2017
Author: meinersbur
Date: Thu Sep 7 05:15:01 2017
New Revision: 312718
URL: http://llvm.org/viewvc/llvm-project?rev=312718&view=rev
Log:
[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.
Added:
polly/trunk/test/Isl/CodeGen/scev_looking_through_bitcasts.ll
Modified:
polly/trunk/lib/CodeGen/BlockGenerators.cpp
Modified: polly/trunk/lib/CodeGen/BlockGenerators.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGen/BlockGenerators.cpp?rev=312718&r1=312717&r2=312718&view=diff
==============================================================================
--- polly/trunk/lib/CodeGen/BlockGenerators.cpp (original)
+++ polly/trunk/lib/CodeGen/BlockGenerators.cpp Thu Sep 7 05:15:01 2017
@@ -692,6 +692,13 @@ void BlockGenerator::generateScalarStore
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);
});
Added: polly/trunk/test/Isl/CodeGen/scev_looking_through_bitcasts.ll
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/Isl/CodeGen/scev_looking_through_bitcasts.ll?rev=312718&view=auto
==============================================================================
--- polly/trunk/test/Isl/CodeGen/scev_looking_through_bitcasts.ll (added)
+++ polly/trunk/test/Isl/CodeGen/scev_looking_through_bitcasts.ll Thu Sep 7 05:15:01 2017
@@ -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
More information about the llvm-commits
mailing list