mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 10:42:39 +01:00
[SimplifyCFG] Fix if conversion with opaque pointers
We need to make sure that the value types are the same. Otherwise we both may not have the necessary dereferenceability implication, nor can we directly form the desired select pattern. Without opaque pointers this is enforced implicitly through the pointer comparison.
This commit is contained in:
parent
f265bf7812
commit
5d9c2de528
@ -2228,6 +2228,7 @@ static Value *isSafeToSpeculateStore(Instruction *I, BasicBlock *BrBB,
|
||||
return nullptr;
|
||||
|
||||
Value *StorePtr = StoreToHoist->getPointerOperand();
|
||||
Type *StoreTy = StoreToHoist->getValueOperand()->getType();
|
||||
|
||||
// Look for a store to the same pointer in BrBB.
|
||||
unsigned MaxNumInstToLookAt = 9;
|
||||
@ -2244,7 +2245,8 @@ static Value *isSafeToSpeculateStore(Instruction *I, BasicBlock *BrBB,
|
||||
|
||||
if (auto *SI = dyn_cast<StoreInst>(&CurI)) {
|
||||
// Found the previous store make sure it stores to the same location.
|
||||
if (SI->getPointerOperand() == StorePtr)
|
||||
if (SI->getPointerOperand() == StorePtr &&
|
||||
SI->getValueOperand()->getType() == StoreTy)
|
||||
// Found the previous store, return its value operand.
|
||||
return SI->getValueOperand();
|
||||
return nullptr; // Unknown store.
|
||||
|
@ -112,6 +112,27 @@ ret.end:
|
||||
ret void
|
||||
}
|
||||
|
||||
define void @different_type(ptr %ptr, i1 %cmp) {
|
||||
; CHECK-LABEL: @different_type(
|
||||
; CHECK-NEXT: store i32 0, ptr [[PTR:%.*]], align 4
|
||||
; CHECK-NEXT: br i1 [[CMP:%.*]], label [[IF_THEN:%.*]], label [[RET_END:%.*]]
|
||||
; CHECK: if.then:
|
||||
; CHECK-NEXT: store i64 1, ptr [[PTR]], align 4
|
||||
; CHECK-NEXT: br label [[RET_END]]
|
||||
; CHECK: ret.end:
|
||||
; CHECK-NEXT: ret void
|
||||
;
|
||||
store i32 0, ptr %ptr
|
||||
br i1 %cmp, label %if.then, label %ret.end
|
||||
|
||||
if.then:
|
||||
store i64 1, ptr %ptr
|
||||
br label %ret.end
|
||||
|
||||
ret.end:
|
||||
ret void
|
||||
}
|
||||
|
||||
; CHECK: !0 = !{!"branch_weights", i32 3, i32 5}
|
||||
!0 = !{!"branch_weights", i32 3, i32 5}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user