[PATCH] D81875: [GlobalISel] Look through extends etc in CombinerHelper::matchConstantOp
Jessica Paquette via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 15 16:37:15 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5a4c3f6b06f6: [GlobalISel] Look through extends etc in CombinerHelper::matchConstantOp (authored by paquette).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D81875/new/
https://reviews.llvm.org/D81875
Files:
llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
llvm/test/CodeGen/AArch64/GlobalISel/prelegalizercombiner-trivial-arith.mir
Index: llvm/test/CodeGen/AArch64/GlobalISel/prelegalizercombiner-trivial-arith.mir
===================================================================
--- llvm/test/CodeGen/AArch64/GlobalISel/prelegalizercombiner-trivial-arith.mir
+++ llvm/test/CodeGen/AArch64/GlobalISel/prelegalizercombiner-trivial-arith.mir
@@ -286,4 +286,24 @@
%op:_(s32) = G_SUB %x(s32), %cst
$w0 = COPY %op(s32)
RET_ReallyLR implicit $w0
+
+...
+---
+name: look_through_zext
+tracksRegLiveness: true
+body: |
+ bb.0:
+ liveins: $x0
+ ; CHECK-LABEL: name: look_through_zext
+ ; CHECK: liveins: $x0
+ ; CHECK: %zero:_(s8) = G_CONSTANT i8 0
+ ; CHECK: %zext_zero:_(s64) = G_ZEXT %zero(s8)
+ ; CHECK: $x0 = COPY %zext_zero(s64)
+ ; CHECK: RET_ReallyLR implicit $x0
+ %zero:_(s8) = G_CONSTANT i8 0
+ %zext_zero:_(s64) = G_ZEXT %zero(s8)
+ %c:_(s64) = G_CONSTANT i64 72340172838076673
+ %mul:_(s64) = G_MUL %c, %zext_zero
+ $x0 = COPY %mul(s64)
+ RET_ReallyLR implicit $x0
...
Index: llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
===================================================================
--- llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
+++ llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
@@ -1617,8 +1617,9 @@
bool CombinerHelper::matchConstantOp(const MachineOperand &MOP, int64_t C) {
if (!MOP.isReg())
return false;
- int64_t Cst;
- return mi_match(MOP.getReg(), MRI, m_ICst(Cst)) && Cst == C;
+ // MIPatternMatch doesn't let us look through G_ZEXT etc.
+ auto ValAndVReg = getConstantVRegValWithLookThrough(MOP.getReg(), MRI);
+ return ValAndVReg && ValAndVReg->Value == C;
}
bool CombinerHelper::replaceSingleDefInstWithOperand(MachineInstr &MI,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81875.270910.patch
Type: text/x-patch
Size: 1728 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200615/c0d53762/attachment.bin>
More information about the llvm-commits
mailing list