diff options
| author | Craig Topper <craig.topper@intel.com> | 2017-11-08 22:26:39 +0000 |
|---|---|---|
| committer | Craig Topper <craig.topper@intel.com> | 2017-11-08 22:26:39 +0000 |
| commit | 61f81f9637cf81ee25d941b09c41a372d9387f3e (patch) | |
| tree | c616307f16839f9dcd59bbf819895c18f8364610 /llvm/test/CodeGen | |
| parent | 55029d811ff8c28fcbfb91faa6c658b59136943c (diff) | |
| download | bcm5719-llvm-61f81f9637cf81ee25d941b09c41a372d9387f3e.tar.gz bcm5719-llvm-61f81f9637cf81ee25d941b09c41a372d9387f3e.zip | |
[X86] Preserve memory refs when folding loads into divides.
This is similar to what we already do for multiplies. Without this we can't unfold and hoist an invariant load.
llvm-svn: 317732
Diffstat (limited to 'llvm/test/CodeGen')
| -rw-r--r-- | llvm/test/CodeGen/X86/hoist-invariant-load.ll | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/llvm/test/CodeGen/X86/hoist-invariant-load.ll b/llvm/test/CodeGen/X86/hoist-invariant-load.ll index e7929c9cecd..a8b4e0a25f9 100644 --- a/llvm/test/CodeGen/X86/hoist-invariant-load.ll +++ b/llvm/test/CodeGen/X86/hoist-invariant-load.ll @@ -1,10 +1,12 @@ ; REQUIRES: asserts -; RUN: llc -mcpu=haswell < %s -stats -O2 2>&1 | grep "4 machinelicm.*hoisted" +; RUN: llc -mcpu=haswell < %s -stats -O2 2>&1 | grep "7 machinelicm.*hoisted" ; For test: ; 2 invariant loads, 1 for OBJC_SELECTOR_REFERENCES_ ; and 1 for objc_msgSend from the GOT ; For test_multi_def: ; 2 invariant load (full multiply, both loads should be hoisted.) +; For test_div_def: +; 2 invariant load (full divide, both loads should be hoisted.) 1 additional instruction for a zeroing edx that gets hoisted and then rematerialized. target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" target triple = "x86_64-apple-macosx10.7.2" @@ -60,4 +62,30 @@ exit: ret void } +define void @test_div_def(i32* dereferenceable(8) %x1, + i32* dereferenceable(8) %x2, + i32* %y, i32 %count) nounwind { +entry: + br label %for.body + +for.check: + %inc = add nsw i32 %i, 1 + %done = icmp sge i32 %inc, %count + br i1 %done, label %exit, label %for.body + +for.body: + %i = phi i32 [ 0, %entry ], [ %inc, %for.check ] + %x1_load = load i32, i32* %x1, align 8, !invariant.load !0 + %x2_load = load i32, i32* %x2, align 8, !invariant.load !0 + %x_quot = udiv i32 %x1_load, %x2_load + %y_elem = getelementptr inbounds i32, i32* %y, i32 %i + %y_load = load i32, i32* %y_elem, align 8 + %y_plus = add i32 %x_quot, %y_load + store i32 %y_plus, i32* %y_elem, align 8 + br label %for.check + +exit: + ret void +} + !0 = !{} |

