[llvm] 7fa5abd - [SelectionDAG] Fix assertion failure with big shift amounts
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Wed May 6 11:58:53 PDT 2020
Author: LemonBoy
Date: 2020-05-06T11:58:37-07:00
New Revision: 7fa5abd3437e94e0983a3baf323cac574d92fc03
URL: https://github.com/llvm/llvm-project/commit/7fa5abd3437e94e0983a3baf323cac574d92fc03
DIFF: https://github.com/llvm/llvm-project/commit/7fa5abd3437e94e0983a3baf323cac574d92fc03.diff
LOG: [SelectionDAG] Fix assertion failure with big shift amounts
Calling getShiftAmountTy with LegalTypes set may return a type that's too narrow to hold the shift amount for integer type it's applied to.
Fixes the regression introduced by D79096
Differential Revision: https://reviews.llvm.org/D79405
Added:
llvm/test/CodeGen/X86/load-local-v3i129.ll
Modified:
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
index 1975f0dde30d..26de8504a549 100644
--- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
@@ -6642,8 +6642,8 @@ TargetLowering::scalarizeVectorLoad(LoadSDNode *LD,
unsigned ShiftIntoIdx =
(DAG.getDataLayout().isBigEndian() ? (NumElem - 1) - Idx : Idx);
SDValue ShiftAmount =
- DAG.getConstant(ShiftIntoIdx * SrcEltVT.getSizeInBits(), SL,
- getShiftAmountTy(LoadVT, DAG.getDataLayout()));
+ DAG.getShiftAmountConstant(ShiftIntoIdx * SrcEltVT.getSizeInBits(),
+ LoadVT, SL, /*LegalTypes=*/false);
SDValue ShiftedElt = DAG.getNode(ISD::SRL, SL, LoadVT, Load, ShiftAmount);
SDValue Elt =
DAG.getNode(ISD::AND, SL, LoadVT, ShiftedElt, SrcEltBitMask);
diff --git a/llvm/test/CodeGen/X86/load-local-v3i129.ll b/llvm/test/CodeGen/X86/load-local-v3i129.ll
new file mode 100644
index 000000000000..00b53ef9740b
--- /dev/null
+++ b/llvm/test/CodeGen/X86/load-local-v3i129.ll
@@ -0,0 +1,34 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=x86_64-unknown-unknown | FileCheck %s
+
+define void @_start() {
+; CHECK-LABEL: _start:
+; CHECK: # %bb.0: # %Entry
+; CHECK-NEXT: pushq %rbp
+; CHECK-NEXT: .cfi_def_cfa_offset 16
+; CHECK-NEXT: .cfi_offset %rbp, -16
+; CHECK-NEXT: movq %rsp, %rbp
+; CHECK-NEXT: .cfi_def_cfa_register %rbp
+; CHECK-NEXT: andq $-128, %rsp
+; CHECK-NEXT: subq $256, %rsp # imm = 0x100
+; CHECK-NEXT: movq {{[0-9]+}}(%rsp), %rax
+; CHECK-NEXT: movq {{[0-9]+}}(%rsp), %rcx
+; CHECK-NEXT: shrdq $2, %rcx, %rax
+; CHECK-NEXT: shrq $2, %rcx
+; CHECK-NEXT: leaq 1(,%rax,4), %rdx
+; CHECK-NEXT: movq %rdx, {{[0-9]+}}(%rsp)
+; CHECK-NEXT: shrdq $62, %rcx, %rax
+; CHECK-NEXT: movq %rax, {{[0-9]+}}(%rsp)
+; CHECK-NEXT: orq $-2, {{[0-9]+}}(%rsp)
+; CHECK-NEXT: movq $-1, {{[0-9]+}}(%rsp)
+; CHECK-NEXT: movq %rbp, %rsp
+; CHECK-NEXT: popq %rbp
+; CHECK-NEXT: .cfi_def_cfa %rsp, 8
+; CHECK-NEXT: retq
+Entry:
+ %y = alloca <3 x i129>, align 4
+ %L = load <3 x i129>, <3 x i129>* %y
+ %I1 = insertelement <3 x i129> %L, i129 340282366920938463463374607431768211455, i32 1
+ store <3 x i129> %I1, <3 x i129>* %y
+ ret void
+}
More information about the llvm-commits
mailing list