OSDN Git Service

[AArch64, x86] add tests for shift-not (PR39657); NFC
authorSanjay Patel <spatel@rotateright.com>
Tue, 20 Nov 2018 15:49:42 +0000 (15:49 +0000)
committerSanjay Patel <spatel@rotateright.com>
Tue, 20 Nov 2018 15:49:42 +0000 (15:49 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@347316 91177308-0d34-0410-b5e6-96231b3b80d8

test/CodeGen/AArch64/xor.ll [new file with mode: 0644]
test/CodeGen/X86/xor.ll

diff --git a/test/CodeGen/AArch64/xor.ll b/test/CodeGen/AArch64/xor.ll
new file mode 100644 (file)
index 0000000..632a3b0
--- /dev/null
@@ -0,0 +1,18 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=aarch64-- | FileCheck %s
+
+define i32 @PR39657(i8* %p, i64 %x) {
+; CHECK-LABEL: PR39657:
+; CHECK:       // %bb.0:
+; CHECK-NEXT:    lsl x8, x1, #2
+; CHECK-NEXT:    eor x8, x8, #0xfffffffffffffffc
+; CHECK-NEXT:    ldr w0, [x0, x8]
+; CHECK-NEXT:    ret
+  %sh = shl i64 %x, 2
+  %mul = xor i64 %sh, -4
+  %add.ptr = getelementptr inbounds i8, i8* %p, i64 %mul
+  %bc = bitcast i8* %add.ptr to i32*
+  %load = load i32, i32* %bc, align 4
+  ret i32 %load
+}
+
index 3aef8dd..29e466e 100644 (file)
@@ -512,3 +512,35 @@ define %struct.ref_s* @test12(%struct.ref_s* %op, i64 %osbot, i64 %intval) {
   %add.ptr = getelementptr inbounds %struct.ref_s, %struct.ref_s* %op, i64 %idx.ext
   ret %struct.ref_s* %add.ptr
 }
+
+define i32 @PR39657(i8* %p, i64 %x) {
+; X32-LABEL: PR39657:
+; X32:       # %bb.0:
+; X32-NEXT:    movl {{[0-9]+}}(%esp), %eax
+; X32-NEXT:    movl {{[0-9]+}}(%esp), %ecx
+; X32-NEXT:    shll $2, %ecx
+; X32-NEXT:    xorl $-4, %ecx
+; X32-NEXT:    movl (%eax,%ecx), %eax
+; X32-NEXT:    retl
+;
+; X64-LIN-LABEL: PR39657:
+; X64-LIN:       # %bb.0:
+; X64-LIN-NEXT:    shlq $2, %rsi
+; X64-LIN-NEXT:    xorq $-4, %rsi
+; X64-LIN-NEXT:    movl (%rdi,%rsi), %eax
+; X64-LIN-NEXT:    retq
+;
+; X64-WIN-LABEL: PR39657:
+; X64-WIN:       # %bb.0:
+; X64-WIN-NEXT:    shlq $2, %rdx
+; X64-WIN-NEXT:    xorq $-4, %rdx
+; X64-WIN-NEXT:    movl (%rcx,%rdx), %eax
+; X64-WIN-NEXT:    retq
+  %sh = shl i64 %x, 2
+  %mul = xor i64 %sh, -4
+  %add.ptr = getelementptr inbounds i8, i8* %p, i64 %mul
+  %bc = bitcast i8* %add.ptr to i32*
+  %load = load i32, i32* %bc, align 4
+  ret i32 %load
+}
+