[llvm] 053c2a0 - [SimplifyCFG][OpaquePtr] Check store type when merging conditional store
Arthur Eubanks via llvm-commits
llvm-commits at lists.llvm.org
Sun Feb 20 11:30:42 PST 2022
Author: Arthur Eubanks
Date: 2022-02-20T11:29:54-08:00
New Revision: 053c2a0020577f7dfbaecf43347b88adf8dc047c
URL: https://github.com/llvm/llvm-project/commit/053c2a0020577f7dfbaecf43347b88adf8dc047c
DIFF: https://github.com/llvm/llvm-project/commit/053c2a0020577f7dfbaecf43347b88adf8dc047c.diff
LOG: [SimplifyCFG][OpaquePtr] Check store type when merging conditional store
Added:
Modified:
llvm/lib/Transforms/Utils/SimplifyCFG.cpp
llvm/test/Transforms/SimplifyCFG/opaque-ptr.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index dbf22ab1e2298..88a7e12a688af 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -3732,7 +3732,9 @@ static bool mergeConditionalStoreToAddress(
return false;
// Now check the stores are compatible.
- if (!QStore->isUnordered() || !PStore->isUnordered())
+ if (!QStore->isUnordered() || !PStore->isUnordered() ||
+ PStore->getValueOperand()->getType() !=
+ QStore->getValueOperand()->getType())
return false;
// Check that sinking the store won't cause program behavior changes. Sinking
diff --git a/llvm/test/Transforms/SimplifyCFG/opaque-ptr.ll b/llvm/test/Transforms/SimplifyCFG/opaque-ptr.ll
index 909346f90d99a..d63fdd7838574 100644
--- a/llvm/test/Transforms/SimplifyCFG/opaque-ptr.ll
+++ b/llvm/test/Transforms/SimplifyCFG/opaque-ptr.ll
@@ -44,3 +44,36 @@ join:
%phi = phi ptr [ %gep1, %if ], [ %gep2, %else]
ret ptr %phi
}
+
+define void @test_cond_store_merge(i1 %arg, i1 %arg2, ptr %p) {
+; CHECK-LABEL: @test_cond_store_merge(
+; CHECK-NEXT: bb:
+; CHECK-NEXT: br i1 [[ARG:%.*]], label [[BB2:%.*]], label [[BB3:%.*]]
+; CHECK: bb2:
+; CHECK-NEXT: store i64 0, ptr [[P:%.*]], align 32
+; CHECK-NEXT: br label [[BB3]]
+; CHECK: bb3:
+; CHECK-NEXT: br i1 [[ARG2:%.*]], label [[BB4:%.*]], label [[BB5:%.*]]
+; CHECK: bb4:
+; CHECK-NEXT: store double 0.000000e+00, ptr [[P]], align 32
+; CHECK-NEXT: br label [[BB5]]
+; CHECK: bb5:
+; CHECK-NEXT: ret void
+;
+bb:
+ br i1 %arg, label %bb2, label %bb3
+
+bb2: ; preds = %bb
+ store i64 0, ptr %p, align 32
+ br label %bb3
+
+bb3: ; preds = %bb2, %bb
+ br i1 %arg2, label %bb4, label %bb5
+
+bb4: ; preds = %bb3
+ store double 0.000000e+00, ptr %p, align 32
+ br label %bb5
+
+bb5: ; preds = %bb4, %bb3
+ ret void
+}
More information about the llvm-commits
mailing list