-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[InstCombine] Combine XOR and AES instructions on ARM/ARM64.
The ARM/ARM64 AESE and AESD instructions have a builtin XOR as the first step in the instruction. Therefore, if the AES key is zero and the AES data was previously XORed, it can be combined into a single instruction. Differential Revision: https://reviews.llvm.org/D47239 Patch by Michael Brase! llvm-svn: 333193
- Loading branch information
Chad Rosier
committed
May 24, 2018
1 parent
451f6c8
commit 274d72f
Showing
3 changed files
with
104 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
llvm/test/Transforms/InstCombine/AArch64/aes-intrinsics.ll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
; RUN: opt -S -instcombine < %s | FileCheck %s | ||
; ARM64 AES intrinsic variants | ||
|
||
define <16 x i8> @combineXorAeseZeroARM64(<16 x i8> %data, <16 x i8> %key) { | ||
; CHECK-LABEL: @combineXorAeseZeroARM64( | ||
; CHECK-NEXT: %data.aes = tail call <16 x i8> @llvm.aarch64.crypto.aese(<16 x i8> %data, <16 x i8> %key) | ||
; CHECK-NEXT: ret <16 x i8> %data.aes | ||
%data.xor = xor <16 x i8> %data, %key | ||
%data.aes = tail call <16 x i8> @llvm.aarch64.crypto.aese(<16 x i8> %data.xor, <16 x i8> zeroinitializer) | ||
ret <16 x i8> %data.aes | ||
} | ||
|
||
define <16 x i8> @combineXorAeseNonZeroARM64(<16 x i8> %data, <16 x i8> %key) { | ||
; CHECK-LABEL: @combineXorAeseNonZeroARM64( | ||
; CHECK-NEXT: %data.xor = xor <16 x i8> %data, %key | ||
; CHECK-NEXT: %data.aes = tail call <16 x i8> @llvm.aarch64.crypto.aese(<16 x i8> %data.xor, <16 x i8> <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1>) | ||
; CHECK-NEXT: ret <16 x i8> %data.aes | ||
%data.xor = xor <16 x i8> %data, %key | ||
%data.aes = tail call <16 x i8> @llvm.aarch64.crypto.aese(<16 x i8> %data.xor, <16 x i8> <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1>) | ||
ret <16 x i8> %data.aes | ||
} | ||
|
||
define <16 x i8> @combineXorAesdZeroARM64(<16 x i8> %data, <16 x i8> %key) { | ||
; CHECK-LABEL: @combineXorAesdZeroARM64( | ||
; CHECK-NEXT: %data.aes = tail call <16 x i8> @llvm.aarch64.crypto.aesd(<16 x i8> %data, <16 x i8> %key) | ||
; CHECK-NEXT: ret <16 x i8> %data.aes | ||
%data.xor = xor <16 x i8> %data, %key | ||
%data.aes = tail call <16 x i8> @llvm.aarch64.crypto.aesd(<16 x i8> %data.xor, <16 x i8> zeroinitializer) | ||
ret <16 x i8> %data.aes | ||
} | ||
|
||
define <16 x i8> @combineXorAesdNonZeroARM64(<16 x i8> %data, <16 x i8> %key) { | ||
; CHECK-LABEL: @combineXorAesdNonZeroARM64( | ||
; CHECK-NEXT: %data.xor = xor <16 x i8> %data, %key | ||
; CHECK-NEXT: %data.aes = tail call <16 x i8> @llvm.aarch64.crypto.aesd(<16 x i8> %data.xor, <16 x i8> <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1>) | ||
; CHECK-NEXT: ret <16 x i8> %data.aes | ||
%data.xor = xor <16 x i8> %data, %key | ||
%data.aes = tail call <16 x i8> @llvm.aarch64.crypto.aesd(<16 x i8> %data.xor, <16 x i8> <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1>) | ||
ret <16 x i8> %data.aes | ||
} | ||
|
||
declare <16 x i8> @llvm.aarch64.crypto.aese(<16 x i8>, <16 x i8>) #0 | ||
declare <16 x i8> @llvm.aarch64.crypto.aesd(<16 x i8>, <16 x i8>) #0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
; RUN: opt -S -instcombine < %s | FileCheck %s | ||
; ARM AES intrinsic variants | ||
|
||
define <16 x i8> @combineXorAeseZeroARM(<16 x i8> %data, <16 x i8> %key) { | ||
; CHECK-LABEL: @combineXorAeseZeroARM( | ||
; CHECK-NEXT: %data.aes = tail call <16 x i8> @llvm.arm.neon.aese(<16 x i8> %data, <16 x i8> %key) | ||
; CHECK-NEXT: ret <16 x i8> %data.aes | ||
%data.xor = xor <16 x i8> %data, %key | ||
%data.aes = tail call <16 x i8> @llvm.arm.neon.aese(<16 x i8> %data.xor, <16 x i8> zeroinitializer) | ||
ret <16 x i8> %data.aes | ||
} | ||
|
||
define <16 x i8> @combineXorAeseNonZeroARM(<16 x i8> %data, <16 x i8> %key) { | ||
; CHECK-LABEL: @combineXorAeseNonZeroARM( | ||
; CHECK-NEXT: %data.xor = xor <16 x i8> %data, %key | ||
; CHECK-NEXT: %data.aes = tail call <16 x i8> @llvm.arm.neon.aese(<16 x i8> %data.xor, <16 x i8> <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1>) | ||
; CHECK-NEXT: ret <16 x i8> %data.aes | ||
%data.xor = xor <16 x i8> %data, %key | ||
%data.aes = tail call <16 x i8> @llvm.arm.neon.aese(<16 x i8> %data.xor, <16 x i8> <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1>) | ||
ret <16 x i8> %data.aes | ||
} | ||
|
||
define <16 x i8> @combineXorAesdZeroARM(<16 x i8> %data, <16 x i8> %key) { | ||
; CHECK-LABEL: @combineXorAesdZeroARM( | ||
; CHECK-NEXT: %data.aes = tail call <16 x i8> @llvm.arm.neon.aesd(<16 x i8> %data, <16 x i8> %key) | ||
; CHECK-NEXT: ret <16 x i8> %data.aes | ||
%data.xor = xor <16 x i8> %data, %key | ||
%data.aes = tail call <16 x i8> @llvm.arm.neon.aesd(<16 x i8> %data.xor, <16 x i8> zeroinitializer) | ||
ret <16 x i8> %data.aes | ||
} | ||
|
||
define <16 x i8> @combineXorAesdNonZeroARM(<16 x i8> %data, <16 x i8> %key) { | ||
; CHECK-LABEL: @combineXorAesdNonZeroARM( | ||
; CHECK-NEXT: %data.xor = xor <16 x i8> %data, %key | ||
; CHECK-NEXT: %data.aes = tail call <16 x i8> @llvm.arm.neon.aesd(<16 x i8> %data.xor, <16 x i8> <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1>) | ||
; CHECK-NEXT: ret <16 x i8> %data.aes | ||
%data.xor = xor <16 x i8> %data, %key | ||
%data.aes = tail call <16 x i8> @llvm.arm.neon.aesd(<16 x i8> %data.xor, <16 x i8> <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1>) | ||
ret <16 x i8> %data.aes | ||
} | ||
|
||
declare <16 x i8> @llvm.arm.neon.aese(<16 x i8>, <16 x i8>) #0 | ||
declare <16 x i8> @llvm.arm.neon.aesd(<16 x i8>, <16 x i8>) #0 |