From 8000c6c535c5a1d8515299072b51fd1baa8b632f Mon Sep 17 00:00:00 2001 From: Evan Cheng Date: Thu, 22 Oct 2009 00:40:00 +0000 Subject: [PATCH] Don't generate sbfx / ubfx with negative lsb field. Patch by David Conrad. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84813 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/ARM/ARMISelDAGToDAG.cpp | 2 +- test/CodeGen/ARM/sbfx.ll | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/Target/ARM/ARMISelDAGToDAG.cpp b/lib/Target/ARM/ARMISelDAGToDAG.cpp index 6e976936d98..5c1835b46a2 100644 --- a/lib/Target/ARM/ARMISelDAGToDAG.cpp +++ b/lib/Target/ARM/ARMISelDAGToDAG.cpp @@ -1287,7 +1287,7 @@ SDNode *ARMDAGToDAGISel::SelectV6T2BitfieldExtractOp(SDValue Op, assert(Srl_imm > 0 && Srl_imm < 32 && "bad amount in shift node!"); unsigned Width = 32 - Srl_imm; int LSB = Srl_imm - Shl_imm; - if ((LSB + Width) > 32) + if (LSB < 0) return NULL; SDValue Reg0 = CurDAG->getRegister(0, MVT::i32); SDValue Ops[] = { Op.getOperand(0).getOperand(0), diff --git a/test/CodeGen/ARM/sbfx.ll b/test/CodeGen/ARM/sbfx.ll index 923f52a8686..6f1d87d2c17 100644 --- a/test/CodeGen/ARM/sbfx.ll +++ b/test/CodeGen/ARM/sbfx.ll @@ -35,3 +35,13 @@ entry: %tmp2 = lshr i32 %tmp, 29 ret i32 %tmp2 } + +define i32 @f5(i32 %a) { +entry: +; CHECK: f5: +; CHECK-NOT: sbfx +; CHECK: bx + %tmp = shl i32 %a, 3 + %tmp2 = ashr i32 %tmp, 1 + ret i32 %tmp2 +}