File tree Expand file tree Collapse file tree 1 file changed +10
-11
lines changed Expand file tree Collapse file tree 1 file changed +10
-11
lines changed Original file line number Diff line number Diff line change @@ -4840,25 +4840,24 @@ static bool isFloatingPointZero(SDValue Op) {
4840
4840
}
4841
4841
4842
4842
static bool shouldBeAdjustedToZero(SDValue LHS, APInt C, ISD::CondCode &CC) {
4843
- // TODO: Can we know ahead of time if we can use a MOVS?
4843
+
4844
+ // setlt and setge are changed to MI and PL for zero respectively, so it is
4845
+ // safe.
4846
+ if (C.isAllOnes() && (CC == ISD::SETLE || CC == ISD::SETGT)) {
4847
+ CC = (CC == ISD::SETLE) ? ISD::SETLT : ISD::SETGE;
4848
+ return true;
4849
+ }
4850
+
4851
+ // On ARM, adds and subs set the V flags correctly, which means the optimizer
4852
+ // can condense to a single adds/subs
4844
4853
switch (LHS.getOpcode()) {
4845
- case ISD::AND:
4846
- case ISD::OR:
4847
- case ISD::XOR:
4848
4854
case ISD::ADD:
4849
4855
case ISD::SUB:
4850
- case ISD::MUL:
4851
- // In ARM, almost every instruction has a variant that sets flags.
4852
4856
break;
4853
4857
default:
4854
4858
return false;
4855
4859
}
4856
4860
4857
- if (C.isAllOnes() && (CC == ISD::SETLE || CC == ISD::SETGT)) {
4858
- CC = (CC == ISD::SETLE) ? ISD::SETLT : ISD::SETGE;
4859
- return true;
4860
- }
4861
-
4862
4861
if (C.isOne() && (CC == ISD::SETLT || CC == ISD::SETGE)) {
4863
4862
CC = (CC == ISD::SETLT) ? ISD::SETLE : ISD::SETGT;
4864
4863
return true;
You can’t perform that action at this time.
0 commit comments