[PATCH] D99908: [GlobalISel] Simplify G_ICMP against true/false when boolean contents are 0/1

Jessica Paquette via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 6 09:51:25 PDT 2021


paquette added inline comments.


================
Comment at: llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp:3908
+  assert(MI.getOpcode() == TargetOpcode::G_ICMP);
+  if (!KB)
+    return false;
----------------
arsenm wrote:
> Is this actually optional?
AArch64PostLegalizerLowering doesn't have it, but maybe it should?

Or maybe I should make this an assert.


================
Comment at: llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp:3917
+    return false;
+  if (getICmpTrueVal(getTargetLowering(), /* IsVector = */ false,
+                     /*IsFP = */ false) != 1)
----------------
arsenm wrote:
> Might as well just handle vectors and pass through isVector?
Sure.


================
Comment at: llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp:3934
+  Builder.setInstrAndDebugLoc(MI);
+  Builder.buildZExtOrTrunc(Dst, LHS);
+  MI.eraseFromParent();
----------------
arsenm wrote:
> This will be the wrong extension type for zero or neg1 boolean
This doesn't handle neg1 boolean anyway, because

```
KnownLHS.getMinValue() == 0 && KnownLHS.getMaxValue() == 1;
```

wouldn't tell us if the constant is exactly one of false/true


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D99908/new/

https://reviews.llvm.org/D99908



More information about the llvm-commits mailing list