[llvm] r326677 - [DAGCombiner] Add a peekThroughBitcast to MergeStoresOfConstantsOrVecElts to fix a crash if we are storing a bitcast of a constant.
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Sun Mar 4 10:51:46 PST 2018
Author: ctopper
Date: Sun Mar 4 10:51:46 2018
New Revision: 326677
URL: http://llvm.org/viewvc/llvm-project?rev=326677&view=rev
Log:
[DAGCombiner] Add a peekThroughBitcast to MergeStoresOfConstantsOrVecElts to fix a crash if we are storing a bitcast of a constant.
Loading a constant into a k-register in AVX512 requires a bitcast from a scalar constant. In the test case here we have a k-register store that gets split into multiple parts of KNL. MergeConsecutiveStores sees each of these pieces as a consecutive store and looks through the bitcast to find the underly scalar constant. But when we went to create the combined store we didn't look through the same bitcast.
Modified:
llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/trunk/test/CodeGen/X86/avx512-mask-op.ll
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=326677&r1=326676&r2=326677&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Sun Mar 4 10:51:46 2018
@@ -12911,6 +12911,7 @@ bool DAGCombiner::MergeStoresOfConstants
StoreSDNode *St = cast<StoreSDNode>(StoreNodes[Idx].MemNode);
SDValue Val = St->getValue();
+ Val = peekThroughBitcast(Val);
StoreInt <<= ElementSizeBits;
if (ConstantSDNode *C = dyn_cast<ConstantSDNode>(Val)) {
StoreInt |= C->getAPIntValue()
Modified: llvm/trunk/test/CodeGen/X86/avx512-mask-op.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/avx512-mask-op.ll?rev=326677&r1=326676&r2=326677&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/avx512-mask-op.ll (original)
+++ llvm/trunk/test/CodeGen/X86/avx512-mask-op.ll Sun Mar 4 10:51:46 2018
@@ -2795,3 +2795,35 @@ entry:
ret <8 x i64> %8
}
+define void @store_v64i1_constant(<64 x i1>* %R) {
+; KNL-LABEL: store_v64i1_constant:
+; KNL: ## %bb.0: ## %entry
+; KNL-NEXT: kxnorw %k0, %k0, %k0
+; KNL-NEXT: kmovw %k0, 2(%rdi)
+; KNL-NEXT: movl $-536871045, 4(%rdi) ## imm = 0xDFFFFF7B
+; KNL-NEXT: movw $-4099, (%rdi) ## imm = 0xEFFD
+; KNL-NEXT: retq
+;
+; SKX-LABEL: store_v64i1_constant:
+; SKX: ## %bb.0: ## %entry
+; SKX-NEXT: movabsq $-2305843576149381123, %rax ## imm = 0xDFFFFF7BFFFFEFFD
+; SKX-NEXT: movq %rax, (%rdi)
+; SKX-NEXT: retq
+;
+; AVX512BW-LABEL: store_v64i1_constant:
+; AVX512BW: ## %bb.0: ## %entry
+; AVX512BW-NEXT: movabsq $-2305843576149381123, %rax ## imm = 0xDFFFFF7BFFFFEFFD
+; AVX512BW-NEXT: movq %rax, (%rdi)
+; AVX512BW-NEXT: retq
+;
+; AVX512DQ-LABEL: store_v64i1_constant:
+; AVX512DQ: ## %bb.0: ## %entry
+; AVX512DQ-NEXT: kxnorw %k0, %k0, %k0
+; AVX512DQ-NEXT: kmovw %k0, 2(%rdi)
+; AVX512DQ-NEXT: movl $-536871045, 4(%rdi) ## imm = 0xDFFFFF7B
+; AVX512DQ-NEXT: movw $-4099, (%rdi) ## imm = 0xEFFD
+; AVX512DQ-NEXT: retq
+entry:
+ store <64 x i1> <i1 1, i1 0, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 0, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 0, i1 1, i1 1, i1 1, i1 1, i1 0, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 1, i1 0, i1 1, i1 1>, <64 x i1>* %R
+ ret void
+}
More information about the llvm-commits
mailing list