Skip to content

Commit 3caeeb2

Browse files
committed
fix: regression and test
1 parent 2ea9898 commit 3caeeb2

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13082,7 +13082,6 @@ static SDValue combineVSelectWithAllOnesOrZeros(SDValue Cond, SDValue TVal,
1308213082

1308313083
assert(CondVT.isVector() && "Vector select expects a vector selector!");
1308413084

13085-
// Classify TVal/FVal content
1308613085
bool IsTAllZero = ISD::isBuildVectorAllZeros(TVal.getNode());
1308713086
bool IsTAllOne = ISD::isBuildVectorAllOnes(TVal.getNode());
1308813087
bool IsFAllZero = ISD::isBuildVectorAllZeros(FVal.getNode());
@@ -13098,6 +13097,18 @@ static SDValue combineVSelectWithAllOnesOrZeros(SDValue Cond, SDValue TVal,
1309813097
: DAG.getConstant(0, DL, VT);
1309913098
}
1310013099

13100+
// check select(setgt lhs, -1), 1, -1 --> or (sra lhs, bitwidth - 1), 1
13101+
APInt TValAPInt;
13102+
if (Cond.getOpcode() == ISD::SETCC &&
13103+
Cond.getOperand(2) == DAG.getCondCode(ISD::SETGT) &&
13104+
Cond.getOperand(0).getValueType() == VT && VT.isSimple() &&
13105+
ISD::isConstantSplatVector(TVal.getNode(), TValAPInt) &&
13106+
TValAPInt.isOne() &&
13107+
ISD::isConstantSplatVectorAllOnes(Cond.getOperand(1).getNode()) &&
13108+
ISD::isConstantSplatVectorAllOnes(FVal.getNode())) {
13109+
return SDValue();
13110+
}
13111+
1310113112
// To use the condition operand as a bitwise mask, it must have elements that
1310213113
// are the same size as the select elements. Ie, the condition operand must
1310313114
// have already been promoted from the IR select condition type <N x i1>.

llvm/test/CodeGen/AArch64/cmp-select-sign.ll

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,9 @@ define i64 @not_sign_i64_4(i64 %a) {
114114
define <7 x i8> @sign_7xi8(<7 x i8> %a) {
115115
; CHECK-LABEL: sign_7xi8:
116116
; CHECK: // %bb.0:
117-
; CHECK-NEXT: movi v1.2d, #0xffffffffffffffff
118-
; CHECK-NEXT: movi v2.8b, #1
119-
; CHECK-NEXT: cmge v0.8b, v1.8b, v0.8b
120-
; CHECK-NEXT: orr v0.8b, v0.8b, v2.8b
117+
; CHECK-NEXT: movi v1.8b, #1
118+
; CHECK-NEXT: cmlt v0.8b, v0.8b, #0
119+
; CHECK-NEXT: orr v0.8b, v0.8b, v1.8b
121120
; CHECK-NEXT: ret
122121
%c = icmp sgt <7 x i8> %a, <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1>
123122
%res = select <7 x i1> %c, <7 x i8> <i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1>, <7 x i8> <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1>
@@ -151,8 +150,7 @@ define <16 x i8> @sign_16xi8(<16 x i8> %a) {
151150
define <3 x i32> @sign_3xi32(<3 x i32> %a) {
152151
; CHECK-LABEL: sign_3xi32:
153152
; CHECK: // %bb.0:
154-
; CHECK-NEXT: movi v1.2d, #0xffffffffffffffff
155-
; CHECK-NEXT: cmge v0.4s, v1.4s, v0.4s
153+
; CHECK-NEXT: cmlt v0.4s, v0.4s, #0
156154
; CHECK-NEXT: orr v0.4s, #1
157155
; CHECK-NEXT: ret
158156
%c = icmp sgt <3 x i32> %a, <i32 -1, i32 -1, i32 -1>

llvm/test/CodeGen/Mips/msa/compare_float.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
2-
; RUN: llc -mtriple=mips-elf -mattr=+msa,+fp64,+mips32r2 < %s | FileCheck %s
2+
; RUN: llc -mtriple=mipsel-elf -mattr=+msa,+fp64,+mips32r2 < %s | FileCheck %s
33

44
declare <4 x float> @llvm.mips.fmax.w(<4 x float>, <4 x float>) nounwind
55
declare <2 x double> @llvm.mips.fmax.d(<2 x double>, <2 x double>) nounwind

0 commit comments

Comments
 (0)