Skip to content

Commit 2908142

Browse files
committed
[X86] Add test coverage for zext(or(shl_nuw(x,c1),c2)) pointer math
Additional test coverage for D155472
1 parent e816c89 commit 2908142

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2+
; RUN: llc < %s -mtriple=i686-unknown | FileCheck %s --check-prefix=X86
3+
; RUN: llc < %s -mtriple=x86_64-unknown | FileCheck %s --check-prefix=X64
4+
5+
define i32 @mask_offset_scale_i32_i64(ptr %base, i32 %i) {
6+
; X86-LABEL: mask_offset_scale_i32_i64:
7+
; X86: # %bb.0:
8+
; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
9+
; X86-NEXT: movzbl {{[0-9]+}}(%esp), %ecx
10+
; X86-NEXT: shll $11, %ecx
11+
; X86-NEXT: movl 48(%eax,%ecx), %eax
12+
; X86-NEXT: retl
13+
;
14+
; X64-LABEL: mask_offset_scale_i32_i64:
15+
; X64: # %bb.0:
16+
; X64-NEXT: # kill: def $esi killed $esi def $rsi
17+
; X64-NEXT: andl $65280, %esi # imm = 0xFF00
18+
; X64-NEXT: addl %esi, %esi
19+
; X64-NEXT: movl 48(%rdi,%rsi,4), %eax
20+
; X64-NEXT: retq
21+
%mask = and i32 %i, 65280
22+
%offset = or i32 %mask, 6
23+
%scale = shl i32 %offset, 1
24+
%idxprom = zext i32 %scale to i64
25+
%arrayidx = getelementptr inbounds i32, ptr %base, i64 %idxprom
26+
%load = load i32, ptr %arrayidx, align 4
27+
ret i32 %load
28+
}

0 commit comments

Comments
 (0)