[llvm] 2908142 - [X86] Add test coverage for zext(or(shl_nuw(x,c1),c2)) pointer math

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 2 04:41:23 PDT 2023


Author: Simon Pilgrim
Date: 2023-10-02T12:38:25+01:00
New Revision: 29081420894eb3ceb9d0c8b6b39092892820a1dc

URL: https://github.com/llvm/llvm-project/commit/29081420894eb3ceb9d0c8b6b39092892820a1dc
DIFF: https://github.com/llvm/llvm-project/commit/29081420894eb3ceb9d0c8b6b39092892820a1dc.diff

LOG: [X86] Add test coverage for zext(or(shl_nuw(x,c1),c2)) pointer math

Additional test coverage for D155472

Added: 
    llvm/test/CodeGen/X86/addr-mode-matcher-3.ll

Modified: 
    

Removed: 
    


################################################################################
diff  --git a/llvm/test/CodeGen/X86/addr-mode-matcher-3.ll b/llvm/test/CodeGen/X86/addr-mode-matcher-3.ll
new file mode 100644
index 000000000000000..0f03276389571e3
--- /dev/null
+++ b/llvm/test/CodeGen/X86/addr-mode-matcher-3.ll
@@ -0,0 +1,28 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=i686-unknown | FileCheck %s --check-prefix=X86
+; RUN: llc < %s -mtriple=x86_64-unknown | FileCheck %s --check-prefix=X64
+
+define i32 @mask_offset_scale_i32_i64(ptr %base, i32 %i) {
+; X86-LABEL: mask_offset_scale_i32_i64:
+; X86:       # %bb.0:
+; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT:    movzbl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT:    shll $11, %ecx
+; X86-NEXT:    movl 48(%eax,%ecx), %eax
+; X86-NEXT:    retl
+;
+; X64-LABEL: mask_offset_scale_i32_i64:
+; X64:       # %bb.0:
+; X64-NEXT:    # kill: def $esi killed $esi def $rsi
+; X64-NEXT:    andl $65280, %esi # imm = 0xFF00
+; X64-NEXT:    addl %esi, %esi
+; X64-NEXT:    movl 48(%rdi,%rsi,4), %eax
+; X64-NEXT:    retq
+  %mask = and i32 %i, 65280
+  %offset = or i32 %mask, 6
+  %scale = shl i32 %offset, 1
+  %idxprom = zext i32 %scale to i64
+  %arrayidx = getelementptr inbounds i32, ptr %base, i64 %idxprom
+  %load = load i32, ptr %arrayidx, align 4
+  ret i32 %load
+}


        


More information about the llvm-commits mailing list