From f2075aef681897e41e45a9686e85d3ddd55d92c0 Mon Sep 17 00:00:00 2001 From: Yonghong Song Date: Thu, 8 Feb 2018 04:37:49 +0000 Subject: 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 Reviewed-by: Yonghong Song Signed-off-by: Jiong Wang llvm-svn: 324560 --- llvm/lib/Target/BPF/BPFISelLowering.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'llvm/lib/Target/BPF') 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(LHS.getNode())) + std::swap(LHS, RHS); + SDValue Ops[] = {LHS, RHS, TargetCC, TrueV, FalseV}; return DAG.getNode(BPFISD::SELECT_CC, DL, VTs, Ops); -- cgit v1.2.3