[PATCH] D71587: Fix a crash in global-isel in dealing with 16bit uadd.with.overflow.
Xiaoqing Wu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 16 18:36:04 PST 2019
xiaoqing_wu created this revision.
Herald added subscribers: llvm-commits, Petar.Avramovic, hiraditya.
Herald added a project: LLVM.
Add support to legalize 16bit uadd.with.overflow
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D71587
Files:
llvm/lib/Target/AArch64/AArch64LegalizerInfo.cpp
llvm/test/CodeGen/AArch64/test-uadd16-with-overflow.mir
Index: llvm/test/CodeGen/AArch64/test-uadd16-with-overflow.mir
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/AArch64/test-uadd16-with-overflow.mir
@@ -0,0 +1,48 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
+# RUN: llc %s -run-pass legalizer -march=arm64 -global-isel=1 -o - | FileCheck %s
+
+...
+---
+name: test-uadd16-withoverflow
+alignment: 4
+tracksRegLiveness: true
+registers:
+ - { id: 0, class: _ }
+ - { id: 1, class: _ }
+ - { id: 2, class: _ }
+ - { id: 3, class: _ }
+ - { id: 4, class: _ }
+ - { id: 5, class: _ }
+liveins:
+ - { reg: '$x0' }
+frameInfo:
+ maxAlignment: 1
+machineFunctionInfo: {}
+body: |
+ bb.1:
+ liveins: $x0
+
+ ; CHECK-LABEL: name: test-uadd16-withoverflow
+ ; CHECK: liveins: $x0
+ ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
+ ; CHECK: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 65535
+ ; CHECK: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64)
+ ; CHECK: [[AND:%[0-9]+]]:_(s32) = G_AND [[TRUNC]], [[C]]
+ ; CHECK: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 2
+ ; CHECK: [[ADD:%[0-9]+]]:_(s32) = G_ADD [[AND]], [[C1]]
+ ; CHECK: [[AND1:%[0-9]+]]:_(s32) = G_AND [[ADD]], [[C]]
+ ; CHECK: [[ICMP:%[0-9]+]]:_(s32) = G_ICMP intpred(ne), [[ADD]](s32), [[AND1]]
+ ; CHECK: [[C2:%[0-9]+]]:_(s64) = G_CONSTANT i64 1
+ ; CHECK: [[ANYEXT:%[0-9]+]]:_(s64) = G_ANYEXT [[ICMP]](s32)
+ ; CHECK: [[AND2:%[0-9]+]]:_(s64) = G_AND [[ANYEXT]], [[C2]]
+ ; CHECK: $x0 = COPY [[AND2]](s64)
+ ; CHECK: RET_ReallyLR implicit $x0
+ %0:_(s64) = COPY $x0
+ %4:_(s16) = G_CONSTANT i16 2
+ %1:_(s16) = G_TRUNC %0(s64)
+ %2:_(s16), %3:_(s1) = G_UADDO %1, %4
+ %5:_(s64) = G_ZEXT %3(s1)
+ $x0 = COPY %5(s64)
+ RET_ReallyLR implicit $x0
+
+...
Index: llvm/lib/Target/AArch64/AArch64LegalizerInfo.cpp
===================================================================
--- llvm/lib/Target/AArch64/AArch64LegalizerInfo.cpp
+++ llvm/lib/Target/AArch64/AArch64LegalizerInfo.cpp
@@ -143,7 +143,8 @@
getActionDefinitionsBuilder({G_SMULH, G_UMULH}).legalFor({s32, s64});
getActionDefinitionsBuilder({G_UADDE, G_USUBE, G_SADDO, G_SSUBO, G_UADDO})
- .legalFor({{s32, s1}, {s64, s1}});
+ .legalFor({{s32, s1}, {s64, s1}})
+ .minScalar(0, s32);
getActionDefinitionsBuilder({G_FADD, G_FSUB, G_FMUL, G_FDIV, G_FNEG})
.legalFor({s32, s64, v2s64, v4s32, v2s32});
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D71587.234213.patch
Type: text/x-patch
Size: 2484 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191217/83661bb5/attachment.bin>
More information about the llvm-commits
mailing list