if (isa<UndefValue>(Val))
return eraseInstFromFunction(SI);
- // The code below needs to be audited and adjusted for unordered atomics
- if (!SI.isSimple())
- return nullptr;
-
// If this store is the last instruction in the basic block (possibly
// excepting debug info instructions), and if the block ends with an
// unconditional branch, try to move it to the successor block.
/// into a phi node with a store in the successor.
///
bool InstCombiner::SimplifyStoreAtEndOfBlock(StoreInst &SI) {
+ assert(SI.isUnordered() &&
+ "this code has not been auditted for volatile or ordered store case");
+
BasicBlock *StoreBB = SI.getParent();
// Check to see if the successor block has exactly two incoming edges. If
store atomic i32* %cast, i32** %p monotonic, align 4
ret i32 0
}
+
+define i32 @test22(i1 %cnd) {
+; CHECK-LABEL: define i32 @test22(
+; CHECK: [[PHI:%.*]] = phi i32
+; CHECK: store atomic i32 [[PHI]], i32* @a unordered, align 4
+ br i1 %cnd, label %block1, label %block2
+
+block1:
+ store atomic i32 1, i32* @a unordered, align 4
+ br label %merge
+block2:
+ store atomic i32 2, i32* @a unordered, align 4
+ br label %merge
+
+merge:
+ ret i32 0
+}
+
+; TODO: probably also legal here
+define i32 @test23(i1 %cnd) {
+; CHECK-LABEL: define i32 @test23(
+; CHECK: br i1 %cnd, label %block1, label %block2
+ br i1 %cnd, label %block1, label %block2
+
+block1:
+ store atomic i32 1, i32* @a monotonic, align 4
+ br label %merge
+block2:
+ store atomic i32 2, i32* @a monotonic, align 4
+ br label %merge
+
+merge:
+ ret i32 0
+}