[PATCH] D36841: [SimplifyCFG] Fix for PR34219: Preserve alignment after merging conditional stores.
Alexey Bataev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 28 07:03:13 PDT 2017
ABataev updated this revision to Diff 112895.
ABataev added a comment.
Update after review
https://reviews.llvm.org/D36841
Files:
lib/Transforms/Utils/SimplifyCFG.cpp
test/Transforms/SimplifyCFG/preserve-store-alignment.ll
Index: test/Transforms/SimplifyCFG/preserve-store-alignment.ll
===================================================================
--- test/Transforms/SimplifyCFG/preserve-store-alignment.ll
+++ test/Transforms/SimplifyCFG/preserve-store-alignment.ll
@@ -25,7 +25,7 @@
; CHECK-NEXT: [[TMP7:%.*]] = xor i1 [[TOBOOL5]], true
; CHECK-NEXT: [[TMP8:%.*]] = or i1 [[TMP6]], [[TMP7]]
; CHECK-NEXT: br i1 [[TMP8]], label [[TMP9:%.*]], label [[TMP10:%.*]]
-; CHECK: store <2 x i64> [[DOT]], <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*)
+; CHECK: store <2 x i64> [[DOT]], <2 x i64>* bitcast (i64* getelementptr inbounds (%struct.Counters, %struct.Counters* @counters, i64 0, i32 1) to <2 x i64>*), align 8
; CHECK-NEXT: br label [[TMP10]]
; CHECK: ret i32 0
;
Index: lib/Transforms/Utils/SimplifyCFG.cpp
===================================================================
--- lib/Transforms/Utils/SimplifyCFG.cpp
+++ lib/Transforms/Utils/SimplifyCFG.cpp
@@ -2966,6 +2966,14 @@
PStore->getAAMetadata(AAMD, /*Merge=*/false);
PStore->getAAMetadata(AAMD, /*Merge=*/true);
SI->setAAMetadata(AAMD);
+ unsigned PAlignment = PStore->getAlignment();
+ unsigned QAlignment = QStore->getAlignment();
+ if (unsigned MinAlignment = std::min(PAlignment, QAlignment))
+ // Choose the minimum of all non-zero alignments.
+ SI->setAlignment(MinAlignment);
+ else if (unsigned MaxAlignment = std::max(PAlignment, QAlignment))
+ // Choose the first non-zero alignment, if any.
+ SI->setAlignment(MaxAlignment);
QStore->eraseFromParent();
PStore->eraseFromParent();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36841.112895.patch
Type: text/x-patch
Size: 1691 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170828/40c0cb4f/attachment.bin>
More information about the llvm-commits
mailing list