From: Arthur Eubanks Date: Sun, 20 Feb 2022 19:29:54 +0000 (-0800) Subject: [SimplifyCFG][OpaquePtr] Check store type when merging conditional store X-Git-Tag: upstream/15.0.7~15816 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=053c2a0020577f7dfbaecf43347b88adf8dc047c;p=platform%2Fupstream%2Fllvm.git [SimplifyCFG][OpaquePtr] Check store type when merging conditional store --- diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index dbf22ab..88a7e12 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 909346f..d63fdd7 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 +}