-
Notifications
You must be signed in to change notification settings - Fork 12.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SDAG] Introduce a new BITREVERSE node along with a corresponding LLV…
…M intrinsic Several backends have instructions to reverse the order of bits in an integer. Conceptually matching such patterns is similar to @llvm.bswap, and it was mentioned in http://reviews.llvm.org/D14234 that it would be best if these patterns were matched in InstCombine instead of reimplemented in every different target. This patch introduces an intrinsic @llvm.bitreverse.i* that operates similarly to @llvm.bswap. For plumbing purposes there is also a new ISD node ISD::BITREVERSE, with simple expansion and promotion support. The intention is that InstCombine's BSWAP detection logic will be extended to support BITREVERSE too, and @llvm.bitreverse intrinsics emitted (if the backend supports lowering it efficiently). llvm-svn: 252878
- Loading branch information
James Molloy
committed
Nov 12, 2015
1 parent
1100940
commit 90111f7
Showing
13 changed files
with
162 additions
and
3 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
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
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
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
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
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
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
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
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
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
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,23 @@ | ||
; RUN: llc -mtriple=aarch64-eabi %s -o - | FileCheck %s | ||
|
||
; These tests just check that the plumbing is in place for @llvm.bitreverse. The | ||
; actual output is massive at the moment as llvm.bitreverse is not yet legal. | ||
|
||
declare <2 x i16> @llvm.bitreverse.v2i16(<2 x i16>) readnone | ||
|
||
define <2 x i16> @f(<2 x i16> %a) { | ||
; CHECK-LABEL: f: | ||
; CHECK: ushr | ||
%b = call <2 x i16> @llvm.bitreverse.v2i16(<2 x i16> %a) | ||
ret <2 x i16> %b | ||
} | ||
|
||
declare i8 @llvm.bitreverse.i8(i8) readnone | ||
|
||
define i8 @g(i8 %a) { | ||
; CHECK-LABEL: g: | ||
; CHECK: lsl | ||
; CHECK: and | ||
%b = call i8 @llvm.bitreverse.i8(i8 %a) | ||
ret i8 %b | ||
} |
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,23 @@ | ||
; RUN: llc -march=ppc64 %s -o - | FileCheck %s | ||
|
||
; These tests just check that the plumbing is in place for @llvm.bitreverse. The | ||
; actual output is massive at the moment as llvm.bitreverse is not yet legal. | ||
|
||
declare <2 x i16> @llvm.bitreverse.v2i16(<2 x i16>) readnone | ||
|
||
define <2 x i16> @f(<2 x i16> %a) { | ||
; CHECK-LABEL: f: | ||
; CHECK: rlwinm | ||
%b = call <2 x i16> @llvm.bitreverse.v2i16(<2 x i16> %a) | ||
ret <2 x i16> %b | ||
} | ||
|
||
declare i8 @llvm.bitreverse.i8(i8) readnone | ||
|
||
define i8 @g(i8 %a) { | ||
; CHECK-LABEL: g: | ||
; CHECK: rlwinm | ||
; CHECK: rlwimi | ||
%b = call i8 @llvm.bitreverse.i8(i8 %a) | ||
ret i8 %b | ||
} |
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,22 @@ | ||
; RUN: llc -march=x86 %s -o - | FileCheck %s | ||
|
||
; These tests just check that the plumbing is in place for @llvm.bitreverse. The | ||
; actual output is massive at the moment as llvm.bitreverse is not yet legal. | ||
|
||
declare <2 x i16> @llvm.bitreverse.v2i16(<2 x i16>) readnone | ||
|
||
define <2 x i16> @f(<2 x i16> %a) { | ||
; CHECK-LABEL: f: | ||
; CHECK: shll | ||
%b = call <2 x i16> @llvm.bitreverse.v2i16(<2 x i16> %a) | ||
ret <2 x i16> %b | ||
} | ||
|
||
declare i8 @llvm.bitreverse.i8(i8) readnone | ||
|
||
define i8 @g(i8 %a) { | ||
; CHECK-LABEL: g: | ||
; CHECK: shlb | ||
%b = call i8 @llvm.bitreverse.i8(i8 %a) | ||
ret i8 %b | ||
} |