summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/BPF
diff options
context:
space:
mode:
authorYonghong Song <yhs@fb.com>2018-02-08 04:37:49 +0000
committerYonghong Song <yhs@fb.com>2018-02-08 04:37:49 +0000
commitf2075aef681897e41e45a9686e85d3ddd55d92c0 (patch)
tree022d6cf6eb93d318ba046fb449e26993de8cdf2e /llvm/lib/Target/BPF
parent8ddd922d7319a7382df0d89df906027058b876f5 (diff)
downloadbcm5719-llvm-f2075aef681897e41e45a9686e85d3ddd55d92c0.tar.gz
bcm5719-llvm-f2075aef681897e41e45a9686e85d3ddd55d92c0.zip
bpf: Improve expanding logic in LowerSELECT_CC
LowerSELECT_CC is not generating optimal Select_Ri pattern at the moment. It is not guaranteed to place ConstantNode at RHS which would miss matching Select_Ri. A new testcase added into the existing select_ri.ll, also there is an existing case in cmp.ll which would be improved to use Select_Ri after this patch, it is adjusted accordingly. Reported-by: Alexei Starovoitov <alexei.starovoitov@gmail.com> Reviewed-by: Yonghong Song <yhs@fb.com> Signed-off-by: Jiong Wang <jiong.wang@netronome.com> llvm-svn: 324560
Diffstat (limited to 'llvm/lib/Target/BPF')
-rw-r--r--llvm/lib/Target/BPF/BPFISelLowering.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/Target/BPF/BPFISelLowering.cpp b/llvm/lib/Target/BPF/BPFISelLowering.cpp
index 3ea96e3148f..2966cf78742 100644
--- a/llvm/lib/Target/BPF/BPFISelLowering.cpp
+++ b/llvm/lib/Target/BPF/BPFISelLowering.cpp
@@ -488,6 +488,11 @@ SDValue BPFTargetLowering::LowerSELECT_CC(SDValue Op, SelectionDAG &DAG) const {
SDValue TargetCC = DAG.getConstant(CC, DL, MVT::i64);
SDVTList VTs = DAG.getVTList(Op.getValueType(), MVT::Glue);
+
+ // The constant is expected at RHS in Select_Ri pattern.
+ if (isa<ConstantSDNode>(LHS.getNode()))
+ std::swap(LHS, RHS);
+
SDValue Ops[] = {LHS, RHS, TargetCC, TrueV, FalseV};
return DAG.getNode(BPFISD::SELECT_CC, DL, VTs, Ops);
OpenPOWER on IntegriCloud