summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
Diffstat (limited to 'llvm')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp7
-rw-r--r--llvm/test/CodeGen/X86/pr30813.s20
2 files changed, 26 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 81fb69f517f..f5aeb8cb533 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -3046,6 +3046,11 @@ SDValue DAGCombiner::visitANDLike(SDValue N0, SDValue N1,
unsigned Size = VT.getSizeInBits();
const APInt &AndMask = CAnd->getAPIntValue();
unsigned ShiftBits = CShift->getZExtValue();
+
+ // Bail out, this node will probably disappear anyway.
+ if (ShiftBits == 0)
+ return SDValue();
+
unsigned MaskBits = AndMask.countTrailingOnes();
EVT HalfVT = EVT::getIntegerVT(*DAG.getContext(), Size / 2);
@@ -3064,7 +3069,7 @@ SDValue DAGCombiner::visitANDLike(SDValue N0, SDValue N1,
// extended to handle extensions mixed in.
SDValue SL(N0);
- assert(ShiftBits != 0 && MaskBits <= Size);
+ assert(MaskBits <= Size);
// Extracting the highest bit of the low half.
EVT ShiftVT = TLI.getShiftAmountTy(HalfVT, DAG.getDataLayout());
diff --git a/llvm/test/CodeGen/X86/pr30813.s b/llvm/test/CodeGen/X86/pr30813.s
new file mode 100644
index 00000000000..cc8726a9353
--- /dev/null
+++ b/llvm/test/CodeGen/X86/pr30813.s
@@ -0,0 +1,20 @@
+ .text
+ .file "/home/davide/work/llvm/test/CodeGen/X86/visitand-shift.ll"
+ .globl patatino
+ .p2align 4, 0x90
+ .type patatino,@function
+patatino: # @patatino
+ .cfi_startproc
+# BB#0:
+ # implicit-def: %RAX
+ movzwl (%rax), %ecx
+ movl %ecx, %eax
+ # implicit-def: %RDX
+ movq %rax, (%rdx)
+ retq
+.Lfunc_end0:
+ .size patatino, .Lfunc_end0-patatino
+ .cfi_endproc
+
+
+ .section ".note.GNU-stack","",@progbits
OpenPOWER on IntegriCloud