Skip to content

Commit 0b74c84

Browse files
committedOct 7, 2018
[DAGCombiner] allow undef elts in vector fabs/fneg matching
This change is proposed as a part of D44548, but we need this independently to avoid regressions from improved undef propagation in SimplifyDemandedVectorElts(). llvm-svn: 343940
1 parent 46a9dc2 commit 0b74c84

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed
 

‎llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -9851,7 +9851,7 @@ static SDValue foldBitcastedFPLogic(SDNode *N, SelectionDAG &DAG,
98519851
// Fold (bitcast int (and (bitcast fp X to int), 0x7fff...) to fp) -> fabs X
98529852
// Fold (bitcast int (xor (bitcast fp X to int), 0x8000...) to fp) -> fneg X
98539853
SDValue LogicOp0 = N0.getOperand(0);
9854-
ConstantSDNode *LogicOp1 = isConstOrConstSplat(N0.getOperand(1));
9854+
ConstantSDNode *LogicOp1 = isConstOrConstSplat(N0.getOperand(1), true);
98559855
if (LogicOp1 && LogicOp1->getAPIntValue() == SignMask &&
98569856
LogicOp0.getOpcode() == ISD::BITCAST &&
98579857
LogicOp0.getOperand(0).getValueType() == VT)

‎llvm/test/CodeGen/X86/fp-logic.ll

+4-6
Original file line numberDiff line numberDiff line change
@@ -323,8 +323,7 @@ define <4 x float> @fadd_bitcast_fneg_vec(<4 x float> %x, <4 x float> %y) {
323323
define <4 x float> @fadd_bitcast_fneg_vec_undef_elts(<4 x float> %x, <4 x float> %y) {
324324
; CHECK-LABEL: fadd_bitcast_fneg_vec_undef_elts:
325325
; CHECK: # %bb.0:
326-
; CHECK-NEXT: xorps {{.*}}(%rip), %xmm1
327-
; CHECK-NEXT: addps %xmm1, %xmm0
326+
; CHECK-NEXT: subps %xmm1, %xmm0
328327
; CHECK-NEXT: retq
329328
%bc1 = bitcast <4 x float> %y to <4 x i32>
330329
%xor = xor <4 x i32> %bc1, <i32 2147483648, i32 2147483648, i32 undef, i32 2147483648>
@@ -345,11 +344,10 @@ define <4 x float> @fsub_bitcast_fneg_vec(<4 x float> %x, <4 x float> %y) {
345344
ret <4 x float> %fsub
346345
}
347346

348-
define <4 x float> @fsub_bitcast_fneg_vec_elts(<4 x float> %x, <4 x float> %y) {
349-
; CHECK-LABEL: fsub_bitcast_fneg_vec_elts:
347+
define <4 x float> @fsub_bitcast_fneg_vec_undef_elts(<4 x float> %x, <4 x float> %y) {
348+
; CHECK-LABEL: fsub_bitcast_fneg_vec_undef_elts:
350349
; CHECK: # %bb.0:
351-
; CHECK-NEXT: xorps {{.*}}(%rip), %xmm1
352-
; CHECK-NEXT: subps %xmm1, %xmm0
350+
; CHECK-NEXT: addps %xmm1, %xmm0
353351
; CHECK-NEXT: retq
354352
%bc1 = bitcast <4 x float> %y to <4 x i32>
355353
%xor = xor <4 x i32> %bc1, <i32 undef, i32 2147483648, i32 undef, i32 2147483648>

0 commit comments

Comments
 (0)