summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/BPF/BPFISelLowering.cpp
diff options
context:
space:
mode:
authorYonghong Song <yhs@fb.com>2018-04-03 03:56:37 +0000
committerYonghong Song <yhs@fb.com>2018-04-03 03:56:37 +0000
commitd3b522f5197df708e42e6debc718b3eb70e30f60 (patch)
tree25ba0175fe77236356e27509c46aa5fef6d8e597 /llvm/lib/Target/BPF/BPFISelLowering.cpp
parentb7322e8ac7a99b059dc7c3930436cebe72b53b8e (diff)
downloadbcm5719-llvm-d3b522f5197df708e42e6debc718b3eb70e30f60.tar.gz
bcm5719-llvm-d3b522f5197df708e42e6debc718b3eb70e30f60.zip
bpf: fix incorrect SELECT_CC lowering
Commit 37962a331c77 ("bpf: Improve expanding logic in LowerSELECT_CC") intended to improve code quality for certain jmp conditions. The commit, however, has a couple of issues: (1). In code, just swap is not enough, ConditionalCode CC should also be swapped, otherwise incorrect code will be generated. (2). The ConditionalCode swap should be subject to getHasJmpExt(). If getHasJmpExt() is False, certain conditional codes will not be supported and swap may generate incorrect code. The original goal for this patch is to optimize jmp operations which does not have JmpExt turned on. If JmpExt is on, better code could be generated. For example, the test select_ri.ll is introduced to demonstrate the optimization. The same result can be achieved with -mcpu=v2 flag. Signed-off-by: Yonghong Song <yhs@fb.com> Acked-by: Alexei Starovoitov <ast@kernel.org> llvm-svn: 329043
Diffstat (limited to 'llvm/lib/Target/BPF/BPFISelLowering.cpp')
-rw-r--r--llvm/lib/Target/BPF/BPFISelLowering.cpp6
1 files changed, 0 insertions, 6 deletions
diff --git a/llvm/lib/Target/BPF/BPFISelLowering.cpp b/llvm/lib/Target/BPF/BPFISelLowering.cpp
index e02cdf579d2..e81c2f5f832 100644
--- a/llvm/lib/Target/BPF/BPFISelLowering.cpp
+++ b/llvm/lib/Target/BPF/BPFISelLowering.cpp
@@ -502,13 +502,7 @@ SDValue BPFTargetLowering::LowerSELECT_CC(SDValue Op, SelectionDAG &DAG) const {
NegateCC(LHS, RHS, CC);
SDValue TargetCC = DAG.getConstant(CC, DL, LHS.getValueType());
-
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