Skip to content
This repository was archived by the owner on Feb 5, 2019. It is now read-only.

Commit 4c9ba56

Browse files
committed
Merging r329852:
------------------------------------------------------------------------ r329852 | nemanjai | 2018-04-11 14:25:44 -0700 (Wed, 11 Apr 2018) | 8 lines [PowerPC] Fix condition for 64-bit rotate when replacing r+r instr with r+i This patch fixes https://bugs.llvm.org/show_bug.cgi?id=37039 The condition only covers one of the two 64-bit rotate instructions. This just adds the second (RLDICLo). Patch by Josh Stone. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_60@330076 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent e73bd18 commit 4c9ba56

File tree

2 files changed

+66
-1
lines changed

2 files changed

+66
-1
lines changed

lib/Target/PowerPC/PPCInstrInfo.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2431,7 +2431,8 @@ bool PPCInstrInfo::convertToImmediateForm(MachineInstr &MI,
24312431
// Use APInt's rotate function.
24322432
int64_t SH = MI.getOperand(2).getImm();
24332433
int64_t MB = MI.getOperand(3).getImm();
2434-
APInt InVal(Opc == PPC::RLDICL ? 64 : 32, SExtImm, true);
2434+
APInt InVal((Opc == PPC::RLDICL || Opc == PPC::RLDICLo) ?
2435+
64 : 32, SExtImm, true);
24352436
InVal = InVal.rotl(SH);
24362437
uint64_t Mask = (1LLU << (63 - MB + 1)) - 1;
24372438
InVal &= Mask;

test/CodeGen/PowerPC/convert-rr-to-ri-instrs.mir

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,16 @@
560560
ret i64 %cond
561561
}
562562

563+
; Function Attrs: norecurse nounwind readnone
564+
define i64 @testRLDICLo3(i64 %a, i64 %b) local_unnamed_addr #0 {
565+
entry:
566+
%shr = lshr i64 %a, 11
567+
%and = and i64 %shr, 16777215
568+
%tobool = icmp eq i64 %and, 0
569+
%cond = select i1 %tobool, i64 %b, i64 %and
570+
ret i64 %cond
571+
}
572+
563573
; Function Attrs: norecurse nounwind readnone
564574
define zeroext i32 @testRLWINM(i32 zeroext %a) local_unnamed_addr #0 {
565575
entry:
@@ -3902,6 +3912,60 @@ body: |
39023912
%x3 = COPY %4
39033913
BLR8 implicit %lr8, implicit %rm, implicit %x3
39043914
3915+
...
3916+
---
3917+
name: testRLDICLo3
3918+
# CHECK-ALL: name: testRLDICLo3
3919+
alignment: 4
3920+
exposesReturnsTwice: false
3921+
legalized: false
3922+
regBankSelected: false
3923+
selected: false
3924+
tracksRegLiveness: true
3925+
registers:
3926+
- { id: 0, class: g8rc, preferred-register: '' }
3927+
- { id: 1, class: g8rc_and_g8rc_nox0, preferred-register: '' }
3928+
- { id: 2, class: g8rc_and_g8rc_nox0, preferred-register: '' }
3929+
- { id: 3, class: crrc, preferred-register: '' }
3930+
- { id: 4, class: g8rc, preferred-register: '' }
3931+
liveins:
3932+
- { reg: '%x3', virtual-reg: '%0' }
3933+
- { reg: '%x4', virtual-reg: '%1' }
3934+
frameInfo:
3935+
isFrameAddressTaken: false
3936+
isReturnAddressTaken: false
3937+
hasStackMap: false
3938+
hasPatchPoint: false
3939+
stackSize: 0
3940+
offsetAdjustment: 0
3941+
maxAlignment: 0
3942+
adjustsStack: false
3943+
hasCalls: false
3944+
stackProtector: ''
3945+
maxCallFrameSize: 4294967295
3946+
hasOpaqueSPAdjustment: false
3947+
hasVAStart: false
3948+
hasMustTailInVarArgFunc: false
3949+
savePoint: ''
3950+
restorePoint: ''
3951+
fixedStack:
3952+
stack:
3953+
constants:
3954+
body: |
3955+
bb.0.entry:
3956+
liveins: %x3, %x4
3957+
3958+
%1 = COPY %x4
3959+
%0 = LI8 2
3960+
%2 = RLDICLo %0, 32, 32, implicit-def %cr0
3961+
; CHECK: ANDIo8 %0, 0
3962+
; CHECK-LATE: li 3, 2
3963+
; CHECK-LATE: andi. 3, 3, 0
3964+
%3 = COPY killed %cr0
3965+
%4 = ISEL8 %1, %2, %3.sub_eq
3966+
%x3 = COPY %4
3967+
BLR8 implicit %lr8, implicit %rm, implicit %x3
3968+
39053969
...
39063970
---
39073971
name: testRLWINM

0 commit comments

Comments
 (0)