[llvm] r358458 - [AArch64][GlobalISel] Don't do extending loads combine for non-pow-2 types.

Amara Emerson via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 15 15:34:08 PDT 2019


Author: aemerson
Date: Mon Apr 15 15:34:08 2019
New Revision: 358458

URL: http://llvm.org/viewvc/llvm-project?rev=358458&view=rev
Log:
[AArch64][GlobalISel] Don't do extending loads combine for non-pow-2 types.

Since non-pow-2 types are going to get split up into multiple loads anyway,
don't do the [SZ]EXTLOAD combine for those and save us trouble later in
legalization.

Added:
    llvm/trunk/test/CodeGen/AArch64/GlobalISel/non-pow-2-extload-combine.mir
Modified:
    llvm/trunk/lib/CodeGen/GlobalISel/CombinerHelper.cpp
    llvm/trunk/test/CodeGen/AArch64/GlobalISel/arm64-fallback.ll

Modified: llvm/trunk/lib/CodeGen/GlobalISel/CombinerHelper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/GlobalISel/CombinerHelper.cpp?rev=358458&r1=358457&r2=358458&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/GlobalISel/CombinerHelper.cpp (original)
+++ llvm/trunk/lib/CodeGen/GlobalISel/CombinerHelper.cpp Mon Apr 15 15:34:08 2019
@@ -194,6 +194,11 @@ bool CombinerHelper::matchCombineExtendi
   if (LoadValueTy.getSizeInBits() < 8)
     return false;
 
+  // For non power-of-2 types, they will very likely be legalized into multiple
+  // loads. Don't bother trying to match them into extending loads.
+  if (!isPowerOf2_32(LoadValueTy.getSizeInBits()))
+    return false;
+
   // Find the preferred type aside from the any-extends (unless it's the only
   // one) and non-extending ops. We'll emit an extending load to that type and
   // and emit a variant of (extend (trunc X)) for the others according to the

Modified: llvm/trunk/test/CodeGen/AArch64/GlobalISel/arm64-fallback.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AArch64/GlobalISel/arm64-fallback.ll?rev=358458&r1=358457&r2=358458&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/AArch64/GlobalISel/arm64-fallback.ll (original)
+++ llvm/trunk/test/CodeGen/AArch64/GlobalISel/arm64-fallback.ll Mon Apr 15 15:34:08 2019
@@ -54,7 +54,7 @@ false:
 
 }
 
-; FALLBACK-WITH-REPORT-ERR: remark: <unknown>:0:0: unable to legalize instruction: %2:_(s32) = G_ZEXTLOAD %1:_(p0) :: (load 3 from `i24* undef`, align 1) (in function: odd_type_load)
+; FALLBACK-WITH-REPORT-ERR: remark: <unknown>:0:0: unable to legalize instruction: %3:_(s32) = G_LOAD %1:_(p0) :: (load 3 from `i24* undef`, align 1) (in function: odd_type_load)
 ; FALLBACK-WITH-REPORT-ERR: warning: Instruction selection used fallback path for odd_type_load
 ; FALLBACK-WITH-REPORT-OUT-LABEL: odd_type_load
 define i32 @odd_type_load() {

Added: llvm/trunk/test/CodeGen/AArch64/GlobalISel/non-pow-2-extload-combine.mir
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AArch64/GlobalISel/non-pow-2-extload-combine.mir?rev=358458&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/AArch64/GlobalISel/non-pow-2-extload-combine.mir (added)
+++ llvm/trunk/test/CodeGen/AArch64/GlobalISel/non-pow-2-extload-combine.mir Mon Apr 15 15:34:08 2019
@@ -0,0 +1,37 @@
+# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
+# RUN: llc -march=aarch64 -run-pass=aarch64-prelegalizer-combiner %s -o - -verify-machineinstrs | FileCheck %s
+--- |
+  target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
+  target triple = "aarch64"
+
+  define i32 @ld_zext_i24(i24* %ptr, i24* %ptr2) {
+    %load = load i24, i24* %ptr, align 1
+    %ext = zext i24 %load to i32
+    ret i32 %ext
+  }
+
+...
+---
+name:            ld_zext_i24
+alignment:       2
+tracksRegLiveness: true
+machineFunctionInfo: {}
+body:             |
+  bb.1 (%ir-block.0):
+    liveins: $x0, $x1
+
+    ; CHECK-LABEL: name: ld_zext_i24
+    ; CHECK: liveins: $x0, $x1
+    ; CHECK: [[COPY:%[0-9]+]]:_(p0) = COPY $x0
+    ; CHECK: [[LOAD:%[0-9]+]]:_(s24) = G_LOAD [[COPY]](p0) :: (load 3 from %ir.ptr, align 1)
+    ; CHECK: [[ZEXT:%[0-9]+]]:_(s32) = G_ZEXT [[LOAD]](s24)
+    ; CHECK: $w0 = COPY [[ZEXT]](s32)
+    ; CHECK: RET_ReallyLR implicit $w0
+    %0:_(p0) = COPY $x0
+    %1:_(p0) = COPY $x1
+    %2:_(s24) = G_LOAD %0(p0) :: (load 3 from %ir.ptr, align 1)
+    %3:_(s32) = G_ZEXT %2(s24)
+    $w0 = COPY %3(s32)
+    RET_ReallyLR implicit $w0
+
+...




More information about the llvm-commits mailing list