If 2 stores in the diamond have common GEP:
bb1: %tmp = getelementptr inbounds i32, i32* %arg1, i64 1 br i1 %arg2, label %bb2, label %bb3 bb2: ; preds = %bb1 store i32 42, i32* %tmp, align 4 br label %bb4 bb3: ; preds = %bb1 store i32 42, i32* %tmp, align 4 br label %bb4 bb4: ; preds = %bb2, %bb3 ret void
Stores will be sunk into %bb4.
Why does it matter here if the address is a GEP, as opposed to some other Value?
Instead of checking equality, could we check if the pointers are MustAlias? Would that have any significant impact on how frequently the transform triggers?