forked from OSchip/llvm-project
when merging two loads, make sure to take the min of their alignment,
not the max. This didn't matter until the previous patch because instcombine would refuse to sink loads with differenting alignments. llvm-svn: 85738
This commit is contained in:
parent
2a249e267a
commit
328ef89bd1
|
@ -10774,7 +10774,7 @@ Instruction *InstCombiner::FoldPHIArgLoadIntoPHI(PHINode &PN) {
|
|||
if ((LoadAlignment != 0) != (LI->getAlignment() != 0))
|
||||
return 0;
|
||||
|
||||
LoadAlignment = std::max(LoadAlignment, LI->getAlignment());
|
||||
LoadAlignment = std::min(LoadAlignment, LI->getAlignment());
|
||||
|
||||
// If the PHI is of volatile loads and the load block has multiple
|
||||
// successors, sinking it would remove a load of the volatile value from
|
||||
|
|
|
@ -157,9 +157,35 @@ bb1:
|
|||
bb2:
|
||||
%E = phi i32 [ %C, %bb ], [ %D, %bb1 ]
|
||||
ret i32 %E
|
||||
; CHECK: @test9
|
||||
; CHECK: bb2:
|
||||
; CHECK-NEXT: phi i32* [ %B, %bb ], [ %A, %bb1 ]
|
||||
; CHECK-NEXT: %E = load i32* %{{[^,]*}}, align 1
|
||||
; CHECK-NEXT: ret i32 %E
|
||||
|
||||
}
|
||||
|
||||
define i32 @test10(i32* %A, i32* %B) {
|
||||
entry:
|
||||
%c = icmp eq i32* %A, null
|
||||
br i1 %c, label %bb1, label %bb
|
||||
|
||||
bb:
|
||||
%C = load i32* %B, align 16
|
||||
br label %bb2
|
||||
|
||||
bb1:
|
||||
%D = load i32* %A, align 32
|
||||
br label %bb2
|
||||
|
||||
bb2:
|
||||
%E = phi i32 [ %C, %bb ], [ %D, %bb1 ]
|
||||
ret i32 %E
|
||||
; CHECK: @test10
|
||||
; CHECK: bb2:
|
||||
; CHECK-NEXT: phi i32* [ %B, %bb ], [ %A, %bb1 ]
|
||||
; CHECK-NEXT: %E = load i32* %{{[^,]*}}, align 16
|
||||
; CHECK-NEXT: ret i32 %E
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue