[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
Thu Aug 17 11:53:59 PDT 2017


ABataev created this revision.

If SimplifyCFG pass is able to merge conditional stores into single one,
it loses the alignment. This may lead to incorrect codegen. Patch
sets the alignment of the new instruction if it is set in the original
one.


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
@@ -2968,6 +2968,8 @@
   PStore->getAAMetadata(AAMD, /*Merge=*/false);
   PStore->getAAMetadata(AAMD, /*Merge=*/true);
   SI->setAAMetadata(AAMD);
+  if (unsigned Alignment = PStore->getAlignment())
+    SI->setAlignment(Alignment);
 
   QStore->eraseFromParent();
   PStore->eraseFromParent();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36841.111539.patch
Type: text/x-patch
Size: 1361 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170817/d10295bd/attachment.bin>


More information about the llvm-commits mailing list