From 8ffc5ca5320db705acbb6f2e42660118c3ff4390 Mon Sep 17 00:00:00 2001 From: Alexei Starovoitov Date: Tue, 31 Mar 2015 02:49:58 +0000 Subject: [PATCH] [bpf] mark mov instructions as ReMaterializable loading immediate into register is cheap, so take advantage of remat. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233666 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/BPF/BPFInstrInfo.td | 7 +++++-- test/CodeGen/BPF/basictest.ll | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/Target/BPF/BPFInstrInfo.td b/lib/Target/BPF/BPFInstrInfo.td index 346c7f9b787..26b2cfebdc8 100644 --- a/lib/Target/BPF/BPFInstrInfo.td +++ b/lib/Target/BPF/BPFInstrInfo.td @@ -231,8 +231,6 @@ class MOV_RI let BPFSrc = 0; // BPF_K let BPFClass = 7; // BPF_ALU64 } -def MOV_rr : MOV_RR<"mov">; -def MOV_ri : MOV_RI<"mov">; class LD_IMM64 Pseudo, string OpcodeStr> : InstBPF<(outs GPR:$dst), (ins u64imm:$imm), @@ -255,7 +253,12 @@ class LD_IMM64 Pseudo, string OpcodeStr> let size = 3; // BPF_DW let BPFClass = 0; // BPF_LD } + +let isReMaterializable = 1, isAsCheapAsAMove = 1 in { def LD_imm64 : LD_IMM64<0, "ld_64">; +def MOV_rr : MOV_RR<"mov">; +def MOV_ri : MOV_RI<"mov">; +} def LD_pseudo : InstBPF<(outs GPR:$dst), (ins i64imm:$pseudo, u64imm:$imm), diff --git a/test/CodeGen/BPF/basictest.ll b/test/CodeGen/BPF/basictest.ll index c0b6af414d0..2a2d49878a6 100644 --- a/test/CodeGen/BPF/basictest.ll +++ b/test/CodeGen/BPF/basictest.ll @@ -8,8 +8,8 @@ define i32 @test0(i32 %X) { } ; CHECK-LABEL: store_imm: -; CHECK: stw 0(r1), r0 -; CHECK: stw 4(r2), r0 +; CHECK: stw 0(r1), r{{[03]}} +; CHECK: stw 4(r2), r{{[03]}} define i32 @store_imm(i32* %a, i32* %b) { entry: store i32 0, i32* %a, align 4 -- 2.34.1