Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CGP] Relax a bit restriction for optimizeMemoryInst to extend scope
CodeGenPrepare::optimizeMemoryInst contains a check that we do nothing if all instructions combining the address for memory instruction is in the same block as memory instruction itself. However if any of these instruction are placed after memory instruction then address calculation will not be folded to memory instruction. The added test case shows an example. Reviewers: loladiro, spatel, efriedma Reviewed By: efriedma Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D34862 llvm-svn: 307628
- Loading branch information
Serguei Katkov
committed
Jul 11, 2017
1 parent
3606ebf
commit 0b7b59a
Showing
2 changed files
with
30 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
; RUN: opt < %s -S -codegenprepare -mtriple=x86_64-unknown-linux-gnu | FileCheck %s | ||
|
||
define i64 @test.after(i8 addrspace(1)* readonly align 8) { | ||
; CHECK-LABEL: test.after | ||
; CHECK: sunkaddr | ||
entry: | ||
%.0 = getelementptr inbounds i8, i8 addrspace(1)* %0, i64 8 | ||
%addr = bitcast i8 addrspace(1)* %.0 to i32 addrspace(1)* | ||
br label %header | ||
|
||
header: | ||
%addr.in.loop = phi i32 addrspace(1)* [ %addr, %entry ], [ %addr.after, %header ] | ||
%local_2_ = phi i64 [ 0, %entry ], [ %.9, %header ] | ||
%.7 = load i32, i32 addrspace(1)* %addr.in.loop, align 8 | ||
fence acquire | ||
%.1 = getelementptr inbounds i8, i8 addrspace(1)* %0, i64 8 | ||
%addr.after = bitcast i8 addrspace(1)* %.1 to i32 addrspace(1)* | ||
%.8 = sext i32 %.7 to i64 | ||
%.9 = add i64 %local_2_, %.8 | ||
%not. = icmp sgt i64 %.9, 999 | ||
br i1 %not., label %exit, label %header | ||
|
||
exit: | ||
ret i64 %.9 | ||
} |