summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Target/X86/X86FastISel.cpp2
-rw-r--r--test/CodeGen/X86/fast-isel-mem.ll12
-rw-r--r--test/CodeGen/X86/fast-isel.ll8
3 files changed, 14 insertions, 8 deletions
diff --git a/lib/Target/X86/X86FastISel.cpp b/lib/Target/X86/X86FastISel.cpp
index 9b784b4449..38aa994a25 100644
--- a/lib/Target/X86/X86FastISel.cpp
+++ b/lib/Target/X86/X86FastISel.cpp
@@ -71,6 +71,8 @@ bool X86FastISel::X86SelectConstAddr(Value *V,
X86AddressMode AM;
AM.GV = GV;
addFullAddress(BuildMI(MBB, TII.get(Opc), Op0), AM);
+ // Prevent loading GV stub multiple times in same MBB.
+ LocalValueMap[V] = Op0;
}
return true;
}
diff --git a/test/CodeGen/X86/fast-isel-mem.ll b/test/CodeGen/X86/fast-isel-mem.ll
new file mode 100644
index 0000000000..81af0ab5a8
--- /dev/null
+++ b/test/CodeGen/X86/fast-isel-mem.ll
@@ -0,0 +1,12 @@
+; RUN: llvm-as < %s | llc -fast-isel -mtriple=i386-apple-darwin -mattr=sse2 | \
+; RUN: grep mov | grep lazy_ptr | count 1
+
+@src = external global i32
+
+define i32 @loadgv() nounwind {
+entry:
+ %0 = load i32* @src, align 4
+ %1 = load i32* @src, align 4
+ %2 = add i32 %0, %1
+ ret i32 %2
+}
diff --git a/test/CodeGen/X86/fast-isel.ll b/test/CodeGen/X86/fast-isel.ll
index 10b2e1ee42..9910629211 100644
--- a/test/CodeGen/X86/fast-isel.ll
+++ b/test/CodeGen/X86/fast-isel.ll
@@ -47,11 +47,3 @@ entry:
%tmp2 = bitcast i32 0 to i32
ret i32 %tmp2
}
-
-@src = external global i32
-
-define i32 @loadgv() nounwind {
-entry:
- %0 = load i32* @src, align 4
- ret i32 %0
-}