[llvm] r291281 - Fix LoopLoadElimination to keep original alignment on the inital hoisted store
Mehdi Amini via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 6 13:06:51 PST 2017
Author: mehdi_amini
Date: Fri Jan 6 15:06:51 2017
New Revision: 291281
URL: http://llvm.org/viewvc/llvm-project?rev=291281&view=rev
Log:
Fix LoopLoadElimination to keep original alignment on the inital hoisted store
This is fixing a bug where Loop Vectorization is widening a load but
with a lower alignment. Hoisting the load without propagating the alignment
will allow inst-combine to later deduce a higher alignment that what the pointer
actually is.
Differential Revision: https://reviews.llvm.org/D28408
Modified:
llvm/trunk/lib/Transforms/Scalar/LoopLoadElimination.cpp
llvm/trunk/test/Transforms/LoopLoadElim/forward.ll
Modified: llvm/trunk/lib/Transforms/Scalar/LoopLoadElimination.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopLoadElimination.cpp?rev=291281&r1=291280&r2=291281&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopLoadElimination.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopLoadElimination.cpp Fri Jan 6 15:06:51 2017
@@ -415,7 +415,9 @@ public:
Value *InitialPtr = SEE.expandCodeFor(PtrSCEV->getStart(), Ptr->getType(),
PH->getTerminator());
Value *Initial =
- new LoadInst(InitialPtr, "load_initial", PH->getTerminator());
+ new LoadInst(InitialPtr, "load_initial", /* isVolatile */ false,
+ Cand.Load->getAlignment(), PH->getTerminator());
+
PHINode *PHI = PHINode::Create(Initial->getType(), 2, "store_forwarded",
&L->getHeader()->front());
PHI->addIncoming(Initial, PH);
Modified: llvm/trunk/test/Transforms/LoopLoadElim/forward.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopLoadElim/forward.ll?rev=291281&r1=291280&r2=291281&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/LoopLoadElim/forward.ll (original)
+++ llvm/trunk/test/Transforms/LoopLoadElim/forward.ll Fri Jan 6 15:06:51 2017
@@ -16,8 +16,8 @@ define void @f(i32* %A, i32* %B, i32* %C
; CHECK-NOT: %found.conflict{{.*}} =
entry:
-; for.body.ph:
-; CHECK: %load_initial = load i32, i32* %A
+; Make sure the hoisted load keeps the alignment
+; CHECK: %load_initial = load i32, i32* %A, align 1
br label %for.body
for.body: ; preds = %for.body, %entry
@@ -34,7 +34,7 @@ for.body:
%a_p1 = add i32 %b, 2
store i32 %a_p1, i32* %Aidx_next, align 4
- %a = load i32, i32* %Aidx, align 4
+ %a = load i32, i32* %Aidx, align 1
; CHECK: %c = mul i32 %store_forwarded, 2
%c = mul i32 %a, 2
store i32 %c, i32* %Cidx, align 4
More information about the llvm-commits
mailing list