summaryrefslogtreecommitdiffstats
path: root/llvm/test/CodeGen
diff options
context:
space:
mode:
authorYonghong Song <yhs@fb.com>2018-03-13 06:47:03 +0000
committerYonghong Song <yhs@fb.com>2018-03-13 06:47:03 +0000
commitc88bcdec432ca22258a1fd8af57d1e97dab7142f (patch)
tree395d77776a1395e8edfe50627f7c40cf5df124df /llvm/test/CodeGen
parent905d13c1230685eb11b2a00b26773f5f052e80db (diff)
downloadbcm5719-llvm-c88bcdec432ca22258a1fd8af57d1e97dab7142f.tar.gz
bcm5719-llvm-c88bcdec432ca22258a1fd8af57d1e97dab7142f.zip
bpf: Extends zero extension elimination beyond comparison instructions
The current zero extension elimination was restricted to operands of comparison. It actually could be extended to more cases. For example: int *inc_p (int *p, unsigned a) { return p + a; } 'a' will be promoted to i64 during addition, and the zero extension could be eliminated as well. For the elimination optimization, it should be much better to start recognizing the candidate sequence from the SRL instruction instead of J* instructions. This patch makes it an generic zero extension elimination pass instead of one restricted with comparison. Signed-off-by: Jiong Wang <jiong.wang@netronome.com> Signed-off-by: Yonghong Song <yhs@fb.com> llvm-svn: 327367
Diffstat (limited to 'llvm/test/CodeGen')
-rw-r--r--llvm/test/CodeGen/BPF/32-bit-subreg-peephole.ll16
1 files changed, 16 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/BPF/32-bit-subreg-peephole.ll b/llvm/test/CodeGen/BPF/32-bit-subreg-peephole.ll
index 78c344b1577..ed5268458f8 100644
--- a/llvm/test/CodeGen/BPF/32-bit-subreg-peephole.ll
+++ b/llvm/test/CodeGen/BPF/32-bit-subreg-peephole.ll
@@ -35,6 +35,11 @@
; else
; return c;
; }
+;
+; int *inc_p (int *p, unsigned a)
+; {
+; return p + a;
+; }
; Function Attrs: norecurse nounwind readnone
define dso_local i64 @select_u(i32 %a, i32 %b, i64 %c, i64 %d) local_unnamed_addr #0 {
@@ -89,3 +94,14 @@ entry:
}
declare dso_local i64 @bar(...) local_unnamed_addr #1
+
+; Function Attrs: norecurse nounwind readnone
+define dso_local i32* @inc_p(i32* readnone %p, i32 %a) local_unnamed_addr #0 {
+; CHECK-LABEL: inc_p:
+entry:
+ %idx.ext = zext i32 %a to i64
+; CHECK-NOT: r{{[0-9]+}} <<= 32
+; CHECK-NOT: r{{[0-9]+}} >>= 32
+ %add.ptr = getelementptr inbounds i32, i32* %p, i64 %idx.ext
+ ret i32* %add.ptr
+}
OpenPOWER on IntegriCloud