Skip to content

Commit 356a2b3

Browse files
committed
Merging r369084:
------------------------------------------------------------------------ r369084 | ctopper | 2019-08-16 06:47:44 +0200 (Fri, 16 Aug 2019) | 5 lines [X86] Manually reimplement getTargetInsertSubreg in X86DAGToDAGISel::matchBitExtract so we can call insertDAGNode on the target constant. This is needed to maintain the topological sort order. Fixes PR42992. ------------------------------------------------------------------------ llvm-svn: 369357
1 parent 0482ca8 commit 356a2b3

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

llvm/lib/Target/X86/X86ISelDAGToDAG.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3333,8 +3333,12 @@ bool X86DAGToDAGISel::matchBitExtract(SDNode *Node) {
33333333
SDValue ImplDef = SDValue(
33343334
CurDAG->getMachineNode(TargetOpcode::IMPLICIT_DEF, DL, MVT::i32), 0);
33353335
insertDAGNode(*CurDAG, SDValue(Node, 0), ImplDef);
3336-
NBits = CurDAG->getTargetInsertSubreg(X86::sub_8bit, DL, MVT::i32, ImplDef,
3337-
NBits);
3336+
3337+
SDValue SRIdxVal = CurDAG->getTargetConstant(X86::sub_8bit, DL, MVT::i32);
3338+
insertDAGNode(*CurDAG, SDValue(Node, 0), SRIdxVal);
3339+
NBits = SDValue(
3340+
CurDAG->getMachineNode(TargetOpcode::INSERT_SUBREG, DL, MVT::i32, ImplDef,
3341+
NBits, SRIdxVal), 0);
33383342
insertDAGNode(*CurDAG, SDValue(Node, 0), NBits);
33393343

33403344
if (Subtarget->hasBMI2()) {

llvm/test/CodeGen/X86/pr42992.ll

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2+
; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=bmi2 | FileCheck %s
3+
4+
define i32 @hoge(i32 %a) {
5+
; CHECK-LABEL: hoge:
6+
; CHECK: # %bb.0: # %bb
7+
; CHECK-NEXT: movl $15, %eax
8+
; CHECK-NEXT: bzhil %edi, %eax, %eax
9+
; CHECK-NEXT: shll $8, %eax
10+
; CHECK-NEXT: retq
11+
bb:
12+
%tmp3 = shl nsw i32 -1, %a
13+
%tmp4 = xor i32 %tmp3, -1
14+
%tmp5 = shl i32 %tmp4, 8
15+
%tmp6 = and i32 %tmp5, 3840
16+
ret i32 %tmp6
17+
}

0 commit comments

Comments
 (0)