[llvm] 3c0735c - [X86] Call insertDAGNode on trunc/zext created in tryShiftAmountMod.
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Mon May 24 10:23:48 PDT 2021
Author: Craig Topper
Date: 2021-05-24T10:23:22-07:00
New Revision: 3c0735c6d8d009dacdb6f63fd3164de54f7121cf
URL: https://github.com/llvm/llvm-project/commit/3c0735c6d8d009dacdb6f63fd3164de54f7121cf
DIFF: https://github.com/llvm/llvm-project/commit/3c0735c6d8d009dacdb6f63fd3164de54f7121cf.diff
LOG: [X86] Call insertDAGNode on trunc/zext created in tryShiftAmountMod.
This puts the new nodes in the proper place in the topologically
sorted list of nodes.
Fixes PR50431, which was introduced recently in D101944.
Added:
llvm/test/CodeGen/X86/pr50431.ll
Modified:
llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
index f3b4b8eeace6f..d692fa0fa492f 100644
--- a/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
+++ b/llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
@@ -3867,8 +3867,12 @@ bool X86DAGToDAGISel::tryShiftAmountMod(SDNode *N) {
Add1 = Add1.getOperand(0);
SubVT = Add1.getValueType();
}
- X = CurDAG->getNode(ISD::ADD, DL, SubVT, Add1,
- CurDAG->getZExtOrTrunc(Add0, DL, SubVT));
+ if (Add0.getValueType() != SubVT) {
+ Add0 = CurDAG->getZExtOrTrunc(Add0, DL, SubVT);
+ insertDAGNode(*CurDAG, OrigShiftAmt, Add0);
+ }
+
+ X = CurDAG->getNode(ISD::ADD, DL, SubVT, Add1, Add0);
insertDAGNode(*CurDAG, OrigShiftAmt, X);
} else
return false;
diff --git a/llvm/test/CodeGen/X86/pr50431.ll b/llvm/test/CodeGen/X86/pr50431.ll
new file mode 100644
index 0000000000000..2b7ff93a935b4
--- /dev/null
+++ b/llvm/test/CodeGen/X86/pr50431.ll
@@ -0,0 +1,40 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+;RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu | FileCheck %s
+
+ at a = dso_local global i32 0, align 4
+
+; Function Attrs: nofree norecurse nounwind uwtable willreturn mustprogress
+define dso_local i32 @main() #0 {
+; CHECK-LABEL: main:
+; CHECK: # %bb.0: # %entry
+; CHECK-NEXT: movl $224, %ecx
+; CHECK-NEXT: addl a(%rip), %ecx
+; CHECK-NEXT: negl %ecx
+; CHECK-NEXT: movl $2, %eax
+; CHECK-NEXT: # kill: def $cl killed $cl killed $ecx
+; CHECK-NEXT: shlq %cl, %rax
+; CHECK-NEXT: testl %eax, %eax
+; CHECK-NEXT: je .LBB0_1
+; CHECK-NEXT: # %bb.2: # %lor.end
+; CHECK-NEXT: xorl %eax, %eax
+; CHECK-NEXT: retq
+; CHECK-NEXT: .LBB0_1: # %lor.rhs
+; CHECK-NEXT: movl a(%rip), %eax
+; CHECK-NEXT: xorl %eax, %eax
+; CHECK-NEXT: retq
+entry:
+ %0 = load volatile i32, i32* @a, align 4
+ %sub = sub i32 -32, %0
+ %sh_prom = zext i32 %sub to i64
+ %shl2 = shl i64 2, %sh_prom
+ %conv = trunc i64 %shl2 to i32
+ %tobool.not = icmp eq i32 %conv, 0
+ br i1 %tobool.not, label %lor.rhs, label %lor.end
+
+lor.rhs: ; preds = %entry
+ %1 = load volatile i32, i32* @a, align 4
+ br label %lor.end
+
+lor.end: ; preds = %lor.rhs, %entry
+ ret i32 0
+}
More information about the llvm-commits
mailing list