[llvm] 8b10aa6 - [AArch64][GlobalISel] Make overflow legalization use clampScalar

Cassie Jones via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 22 16:59:51 PST 2021


Author: Cassie Jones
Date: 2021-02-22T19:59:36-05:00
New Revision: 8b10aa67ad5c97ece9ddb699adeae1ae85a5b28d

URL: https://github.com/llvm/llvm-project/commit/8b10aa67ad5c97ece9ddb699adeae1ae85a5b28d
DIFF: https://github.com/llvm/llvm-project/commit/8b10aa67ad5c97ece9ddb699adeae1ae85a5b28d.diff

LOG: [AArch64][GlobalISel] Make overflow legalization use clampScalar

Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D96674

Added: 
    

Modified: 
    llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp
    llvm/test/CodeGen/AArch64/GlobalISel/legalize-uaddo.mir
    llvm/test/CodeGen/AArch64/GlobalISel/legalize-usubo.mir

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp b/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp
index 55c4028e7ce0..449e50f07c45 100644
--- a/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp
+++ b/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp
@@ -168,7 +168,8 @@ AArch64LegalizerInfo::AArch64LegalizerInfo(const AArch64Subtarget &ST)
   getActionDefinitionsBuilder(
       {G_SADDE, G_SSUBE, G_UADDE, G_USUBE, G_SADDO, G_SSUBO, G_UADDO, G_USUBO})
       .legalFor({{s32, s1}, {s64, s1}})
-      .minScalar(0, s32);
+      .clampScalar(0, s32, s64)
+      .widenScalarToNextPow2(0);
 
   getActionDefinitionsBuilder({G_FADD, G_FSUB, G_FMUL, G_FDIV, G_FNEG})
       .legalFor({s32, s64, v2s64, v4s32, v2s32})

diff  --git a/llvm/test/CodeGen/AArch64/GlobalISel/legalize-uaddo.mir b/llvm/test/CodeGen/AArch64/GlobalISel/legalize-uaddo.mir
index d938e96953c5..1ee1de952365 100644
--- a/llvm/test/CodeGen/AArch64/GlobalISel/legalize-uaddo.mir
+++ b/llvm/test/CodeGen/AArch64/GlobalISel/legalize-uaddo.mir
@@ -1,6 +1,67 @@
 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
 # RUN: llc -mtriple aarch64 -verify-machineinstrs -run-pass=legalizer -debugify-and-strip-all-safe %s -o - | FileCheck %s
 
+---
+name:            narrow_scalar_uaddo_s128
+body:             |
+  bb.0.entry:
+    ; CHECK-LABEL: name: narrow_scalar_uaddo_s128
+    ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
+    ; CHECK: [[COPY1:%[0-9]+]]:_(s64) = COPY $x1
+    ; CHECK: [[COPY2:%[0-9]+]]:_(s64) = COPY $x2
+    ; CHECK: [[COPY3:%[0-9]+]]:_(s64) = COPY $x3
+    ; CHECK: [[UADDO:%[0-9]+]]:_(s64), [[UADDO1:%[0-9]+]]:_(s1) = G_UADDO [[COPY]], [[COPY2]]
+    ; CHECK: %17:_(s64), %carry_out:_(s1) = G_UADDE [[COPY1]], [[COPY3]], [[UADDO1]]
+    ; CHECK: %carry_out_ext:_(s64) = G_ANYEXT %carry_out(s1)
+    ; CHECK: $x0 = COPY [[UADDO]](s64)
+    ; CHECK: $x1 = COPY %17(s64)
+    ; CHECK: $x2 = COPY %carry_out_ext(s64)
+    %0:_(s64) = COPY $x0
+    %1:_(s64) = COPY $x1
+    %2:_(s64) = COPY $x2
+    %3:_(s64) = COPY $x3
+    %lhs:_(s128) = G_MERGE_VALUES %0, %1
+    %rhs:_(s128) = G_MERGE_VALUES %2, %3
+    %add:_(s128), %carry_out:_(s1) = G_UADDO %lhs, %rhs
+    %add0:_(s64), %add1:_(s64) = G_UNMERGE_VALUES %add
+    %carry_out_ext:_(s64) = G_ANYEXT %carry_out
+    $x0 = COPY %add0
+    $x1 = COPY %add1
+    $x2 = COPY %carry_out_ext
+
+...
+---
+name:            narrow_scalar_uaddo_big_nonpow2
+body:             |
+  bb.0.entry:
+    ; CHECK-LABEL: name: narrow_scalar_uaddo_big_nonpow2
+    ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
+    ; CHECK: [[COPY1:%[0-9]+]]:_(s64) = COPY $x1
+    ; CHECK: [[COPY2:%[0-9]+]]:_(s64) = COPY $x2
+    ; CHECK: [[COPY3:%[0-9]+]]:_(s64) = COPY $x3
+    ; CHECK: [[UADDO:%[0-9]+]]:_(s64), [[UADDO1:%[0-9]+]]:_(s1) = G_UADDO [[COPY]], [[COPY1]]
+    ; CHECK: [[UADDE:%[0-9]+]]:_(s64), [[UADDE1:%[0-9]+]]:_(s1) = G_UADDE [[COPY1]], [[COPY2]], [[UADDO1]]
+    ; CHECK: %22:_(s64), %carry_out:_(s1) = G_UADDE [[COPY2]], [[COPY3]], [[UADDE1]]
+    ; CHECK: %carry_out_ext:_(s64) = G_ANYEXT %carry_out(s1)
+    ; CHECK: $x0 = COPY [[UADDO]](s64)
+    ; CHECK: $x1 = COPY [[UADDE]](s64)
+    ; CHECK: $x2 = COPY %22(s64)
+    ; CHECK: $x3 = COPY %carry_out_ext(s64)
+    %0:_(s64) = COPY $x0
+    %1:_(s64) = COPY $x1
+    %2:_(s64) = COPY $x2
+    %3:_(s64) = COPY $x3
+    %lhs:_(s192) = G_MERGE_VALUES %0, %1, %2
+    %rhs:_(s192) = G_MERGE_VALUES %1, %2, %3
+    %add:_(s192), %carry_out:_(s1) = G_UADDO %lhs, %rhs
+    %add0:_(s64), %add1:_(s64), %add2:_(s64) = G_UNMERGE_VALUES %add
+    %carry_out_ext:_(s64) = G_ANYEXT %carry_out
+    $x0 = COPY %add0
+    $x1 = COPY %add1
+    $x2 = COPY %add2
+    $x3 = COPY %carry_out_ext
+
+...
 ---
 name:            test_scalar_uaddo_small
 body:             |

diff  --git a/llvm/test/CodeGen/AArch64/GlobalISel/legalize-usubo.mir b/llvm/test/CodeGen/AArch64/GlobalISel/legalize-usubo.mir
index d38e51466ab0..b16343bf0134 100644
--- a/llvm/test/CodeGen/AArch64/GlobalISel/legalize-usubo.mir
+++ b/llvm/test/CodeGen/AArch64/GlobalISel/legalize-usubo.mir
@@ -1,6 +1,67 @@
 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
 # RUN: llc -mtriple aarch64 -verify-machineinstrs -run-pass=legalizer -debugify-and-strip-all-safe %s -o - | FileCheck %s
 
+---
+name:            narrow_scalar_usubo_s128
+body:             |
+  bb.0.entry:
+    ; CHECK-LABEL: name: narrow_scalar_usubo_s128
+    ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
+    ; CHECK: [[COPY1:%[0-9]+]]:_(s64) = COPY $x1
+    ; CHECK: [[COPY2:%[0-9]+]]:_(s64) = COPY $x2
+    ; CHECK: [[COPY3:%[0-9]+]]:_(s64) = COPY $x3
+    ; CHECK: [[USUBO:%[0-9]+]]:_(s64), [[USUBO1:%[0-9]+]]:_(s1) = G_USUBO [[COPY]], [[COPY2]]
+    ; CHECK: %17:_(s64), %carry_out:_(s1) = G_USUBE [[COPY1]], [[COPY3]], [[USUBO1]]
+    ; CHECK: %carry_out_ext:_(s64) = G_ANYEXT %carry_out(s1)
+    ; CHECK: $x0 = COPY [[USUBO]](s64)
+    ; CHECK: $x1 = COPY %17(s64)
+    ; CHECK: $x2 = COPY %carry_out_ext(s64)
+    %0:_(s64) = COPY $x0
+    %1:_(s64) = COPY $x1
+    %2:_(s64) = COPY $x2
+    %3:_(s64) = COPY $x3
+    %lhs:_(s128) = G_MERGE_VALUES %0, %1
+    %rhs:_(s128) = G_MERGE_VALUES %2, %3
+    %sub:_(s128), %carry_out:_(s1) = G_USUBO %lhs, %rhs
+    %sub0:_(s64), %sub1:_(s64) = G_UNMERGE_VALUES %sub
+    %carry_out_ext:_(s64) = G_ANYEXT %carry_out
+    $x0 = COPY %sub0
+    $x1 = COPY %sub1
+    $x2 = COPY %carry_out_ext
+
+...
+---
+name:            narrow_scalar_usubo_big_nonpow2
+body:             |
+  bb.0.entry:
+    ; CHECK-LABEL: name: narrow_scalar_usubo_big_nonpow2
+    ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
+    ; CHECK: [[COPY1:%[0-9]+]]:_(s64) = COPY $x1
+    ; CHECK: [[COPY2:%[0-9]+]]:_(s64) = COPY $x2
+    ; CHECK: [[COPY3:%[0-9]+]]:_(s64) = COPY $x3
+    ; CHECK: [[USUBO:%[0-9]+]]:_(s64), [[USUBO1:%[0-9]+]]:_(s1) = G_USUBO [[COPY]], [[COPY1]]
+    ; CHECK: [[USUBE:%[0-9]+]]:_(s64), [[USUBE1:%[0-9]+]]:_(s1) = G_USUBE [[COPY1]], [[COPY2]], [[USUBO1]]
+    ; CHECK: %22:_(s64), %carry_out:_(s1) = G_USUBE [[COPY2]], [[COPY3]], [[USUBE1]]
+    ; CHECK: %carry_out_ext:_(s64) = G_ANYEXT %carry_out(s1)
+    ; CHECK: $x0 = COPY [[USUBO]](s64)
+    ; CHECK: $x1 = COPY [[USUBE]](s64)
+    ; CHECK: $x2 = COPY %22(s64)
+    ; CHECK: $x3 = COPY %carry_out_ext(s64)
+    %0:_(s64) = COPY $x0
+    %1:_(s64) = COPY $x1
+    %2:_(s64) = COPY $x2
+    %3:_(s64) = COPY $x3
+    %lhs:_(s192) = G_MERGE_VALUES %0, %1, %2
+    %rhs:_(s192) = G_MERGE_VALUES %1, %2, %3
+    %sub:_(s192), %carry_out:_(s1) = G_USUBO %lhs, %rhs
+    %sub0:_(s64), %sub1:_(s64), %sub2:_(s64) = G_UNMERGE_VALUES %sub
+    %carry_out_ext:_(s64) = G_ANYEXT %carry_out
+    $x0 = COPY %sub0
+    $x1 = COPY %sub1
+    $x2 = COPY %sub2
+    $x3 = COPY %carry_out_ext
+
+...
 ---
 name:            test_scalar_usubo_small
 body:             |


        


More information about the llvm-commits mailing list