llvm.org GIT mirror llvm / ce22881
[PPC CodeGen] Fix the bitreverse.i64 intrinsic. Summary: The two 32-bit words were swapped. Subscribers: nemanjai, kbarton Differential Revision: https://reviews.llvm.org/D38705 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316270 91177308-0d34-0410-b5e6-96231b3b80d8 Fangrui Song 2 years ago
2 changed file(s) with 24 addition(s) and 22 deletion(s). Raw diff Collapse all Expand all
46674667 }
46684668
46694669 def ExtendLo32 {
4670 dag To64Bit =
4670 dag ToLo32 =
46714671 (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)),
46724672 DWLo32RotateInsertByte1.Left, sub_32));
46734673 }
46944694 (RLWIMI DWHi32RotateInsertByte3.Left, DWExtractHi32.SubReg, 8, 24, 31);
46954695 }
46964696
4697 def ExtendHi32 {
4698 dag To64Bit =
4697 def MoveHi32 {
4698 dag ToLo32 =
46994699 (i64 (INSERT_SUBREG (i64 (IMPLICIT_DEF)),
47004700 DWHi32RotateInsertByte1.Left, sub_32));
47014701 }
47024702
4703 def DWShiftLo32 { // SLDI ExtendHi32.To64Bit, 32
4704 dag ToHi32 = (RLDICR ExtendHi32.To64Bit, 32, 31);
4703 // Now byte-swap within the high word and low word both are done, next
4704 // swap the high word and low word.
4705 def DWShiftLo32 { // SLDI ExtendLo32.ToLo32, 32
4706 dag ToHi32 = (RLDICR ExtendLo32.ToLo32, 32, 31);
47054707 }
47064708
47074709 def : Pat<(i64 (bitreverse i64:$A)),
4708 (OR8 DWShiftLo32.ToHi32, ExtendLo32.To64Bit)>;
4710 (OR8 DWShiftLo32.ToHi32, MoveHi32.ToLo32)>;
6666 ; CHECK-NEXT: and 4, 8, 4
6767 ; CHECK-NEXT: lis 7, 3855
6868 ; CHECK-NEXT: or 3, 3, 4
69 ; CHECK-NEXT: oris 12, 5, 52428
70 ; CHECK-NEXT: oris 9, 6, 13107
69 ; CHECK-NEXT: oris 9, 5, 52428
70 ; CHECK-NEXT: oris 10, 6, 13107
7171 ; CHECK-NEXT: lis 6, -3856
7272 ; CHECK-NEXT: ori 7, 7, 3855
7373 ; CHECK-NEXT: sldi 8, 3, 2
74 ; CHECK-NEXT: ori 4, 12, 52428
74 ; CHECK-NEXT: ori 4, 9, 52428
7575 ; CHECK-NEXT: rldicl 3, 3, 62, 2
76 ; CHECK-NEXT: ori 5, 9, 13107
76 ; CHECK-NEXT: ori 5, 10, 13107
7777 ; CHECK-NEXT: ori 6, 6, 61680
7878 ; CHECK-NEXT: and 3, 3, 5
7979 ; CHECK-NEXT: sldi 5, 6, 32
8080 ; CHECK-NEXT: and 4, 8, 4
8181 ; CHECK-NEXT: sldi 6, 7, 32
8282 ; CHECK-NEXT: or 3, 3, 4
83 ; CHECK-NEXT: oris 10, 5, 61680
84 ; CHECK-NEXT: oris 11, 6, 3855
83 ; CHECK-NEXT: oris 11, 5, 61680
84 ; CHECK-NEXT: oris 12, 6, 3855
8585 ; CHECK-NEXT: sldi 6, 3, 4
86 ; CHECK-NEXT: ori 4, 10, 61680
86 ; CHECK-NEXT: ori 4, 11, 61680
8787 ; CHECK-NEXT: rldicl 3, 3, 60, 4
88 ; CHECK-NEXT: ori 5, 11, 3855
88 ; CHECK-NEXT: ori 5, 12, 3855
8989 ; CHECK-NEXT: and 4, 6, 4
9090 ; CHECK-NEXT: and 3, 3, 5
9191 ; CHECK-NEXT: or 3, 3, 4
92 ; CHECK-NEXT: rlwinm 5, 3, 24, 0, 31
9293 ; CHECK-NEXT: rldicl 4, 3, 32, 32
93 ; CHECK-NEXT: rlwinm 6, 3, 24, 0, 31
94 ; CHECK-NEXT: rlwinm 5, 4, 24, 0, 31
95 ; CHECK-NEXT: rlwimi 6, 3, 8, 8, 15
96 ; CHECK-NEXT: rlwimi 5, 4, 8, 8, 15
97 ; CHECK-NEXT: rlwimi 6, 3, 8, 24, 31
98 ; CHECK-NEXT: rlwimi 5, 4, 8, 24, 31
99 ; CHECK-NEXT: sldi 12, 5, 32
100 ; CHECK-NEXT: or 3, 12, 6
94 ; CHECK-NEXT: rlwinm 6, 4, 24, 0, 31
95 ; CHECK-NEXT: rlwimi 5, 3, 8, 8, 15
96 ; CHECK-NEXT: rlwimi 6, 4, 8, 8, 15
97 ; CHECK-NEXT: rlwimi 5, 3, 8, 24, 31
98 ; CHECK-NEXT: rlwimi 6, 4, 8, 24, 31
99 ; CHECK-NEXT: sldi 3, 5, 32
100 ; CHECK-NEXT: or 3, 3, 6
101101 ; CHECK-NEXT: blr
102102 %res = call i64 @llvm.bitreverse.i64(i64 %arg)
103103 ret i64 %res