diff options
| author | Zi Xuan Wu <wuzish@cn.ibm.com> | 2019-01-09 02:31:10 +0000 |
|---|---|---|
| committer | Zi Xuan Wu <wuzish@cn.ibm.com> | 2019-01-09 02:31:10 +0000 |
| commit | 9479f6d72e7d148aa1783bf229416e55791b09e9 (patch) | |
| tree | 0c136934dd86b963353806b4d8804b852b014880 /llvm | |
| parent | ed0d6c60afd8a9007862b3ca0f69dd42cfcfc357 (diff) | |
| download | bcm5719-llvm-9479f6d72e7d148aa1783bf229416e55791b09e9.tar.gz bcm5719-llvm-9479f6d72e7d148aa1783bf229416e55791b09e9.zip | |
[PowerPC] Fix assert from machine verify pass that unmatched register class about fcmp selection in fast-isel
Bad machine code: Illegal virtual register for instruction
function: TestULE
basic block: %bb.0 entry (0x1000a39b158)
instruction: %2:crrc = FCMPUD %1:vsfrc, %3:f8rc
operand 1: %1:vsfrc
Fix assert about missing match between fcmp instruction and register class.
We should use vsx related cmp instruction xvcmpudp instead of fcmpu when vsx is opened.
add -verifymachineinstrs option into related test cases to enable the verify pass.
Differential Revision: https://reviews.llvm.org/D55686
llvm-svn: 350685
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/lib/Target/PowerPC/PPCFastISel.cpp | 33 | ||||
| -rw-r--r-- | llvm/test/CodeGen/PowerPC/fast-isel-fcmp-nan.ll | 14 | ||||
| -rw-r--r-- | llvm/test/CodeGen/PowerPC/vsx-self-copy.ll | 4 |
3 files changed, 29 insertions, 22 deletions
diff --git a/llvm/lib/Target/PowerPC/PPCFastISel.cpp b/llvm/lib/Target/PowerPC/PPCFastISel.cpp index aa55ac1f7ac..1fb81cc87d8 100644 --- a/llvm/lib/Target/PowerPC/PPCFastISel.cpp +++ b/llvm/lib/Target/PowerPC/PPCFastISel.cpp @@ -861,8 +861,20 @@ bool PPCFastISel::PPCEmitCmp(const Value *SrcValue1, const Value *SrcValue2, } } + unsigned SrcReg1 = getRegForValue(SrcValue1); + if (SrcReg1 == 0) + return false; + + unsigned SrcReg2 = 0; + if (!UseImm) { + SrcReg2 = getRegForValue(SrcValue2); + if (SrcReg2 == 0) + return false; + } + unsigned CmpOpc; bool NeedsExt = false; + auto RC = MRI.getRegClass(SrcReg1); switch (SrcVT.SimpleTy) { default: return false; case MVT::f32: @@ -879,8 +891,11 @@ bool PPCFastISel::PPCEmitCmp(const Value *SrcValue1, const Value *SrcValue2, CmpOpc = PPC::EFSCMPGT; break; } - } else + } else if (isVSSRCRegClass(RC)) { + llvm_unreachable("Unsupposed f32 VSX comparison"); + } else { CmpOpc = PPC::FCMPUS; + } break; case MVT::f64: if (HasSPE) { @@ -896,8 +911,11 @@ bool PPCFastISel::PPCEmitCmp(const Value *SrcValue1, const Value *SrcValue2, CmpOpc = PPC::EFDCMPGT; break; } - } else + } else if (isVSFRCRegClass(RC)) { + CmpOpc = PPC::XSCMPUDP; + } else { CmpOpc = PPC::FCMPUD; + } break; case MVT::i1: case MVT::i8: @@ -918,17 +936,6 @@ bool PPCFastISel::PPCEmitCmp(const Value *SrcValue1, const Value *SrcValue2, break; } - unsigned SrcReg1 = getRegForValue(SrcValue1); - if (SrcReg1 == 0) - return false; - - unsigned SrcReg2 = 0; - if (!UseImm) { - SrcReg2 = getRegForValue(SrcValue2); - if (SrcReg2 == 0) - return false; - } - if (NeedsExt) { unsigned ExtReg = createResultReg(&PPC::GPRCRegClass); if (!PPCEmitIntExt(SrcVT, SrcReg1, MVT::i32, ExtReg, IsZExt)) diff --git a/llvm/test/CodeGen/PowerPC/fast-isel-fcmp-nan.ll b/llvm/test/CodeGen/PowerPC/fast-isel-fcmp-nan.ll index f060395bb24..84d4614e56a 100644 --- a/llvm/test/CodeGen/PowerPC/fast-isel-fcmp-nan.ll +++ b/llvm/test/CodeGen/PowerPC/fast-isel-fcmp-nan.ll @@ -1,4 +1,4 @@ -; RUN: llc -mtriple powerpc64le-unknown-linux-gnu -fast-isel -O0 < %s | FileCheck %s +; RUN: llc -verify-machineinstrs -mtriple powerpc64le-unknown-linux-gnu -fast-isel -O0 < %s | FileCheck %s define i1 @TestULT(double %t0) { ; CHECK-LABEL: TestULT: @@ -17,7 +17,7 @@ good: define i1 @TestULE(double %t0) { ; CHECK-LABEL: TestULE: -; CHECK: fcmpu +; CHECK: xscmpudp ; CHECK-NEXT: ble ; CHECK: blr entry: @@ -33,7 +33,7 @@ good: define i1 @TestUNE(double %t0) { ; CHECK-LABEL: TestUNE: -; CHECK: fcmpu +; CHECK: xscmpudp ; CHECK-NEXT: bne ; CHECK: blr entry: @@ -79,7 +79,7 @@ good: define i1 @TestUGE(double %t0) { ; CHECK-LABEL: TestUGE: -; CHECK: fcmpu +; CHECK: xscmpudp ; CHECK-NEXT: bge ; CHECK: blr entry: @@ -95,7 +95,7 @@ good: define i1 @TestOLT(double %t0) { ; CHECK-LABEL: TestOLT: -; CHECK: fcmpu +; CHECK: xscmpudp ; CHECK-NEXT: blt ; CHECK: blr entry: @@ -141,7 +141,7 @@ good: define i1 @TestOEQ(double %t0) { ; CHECK-LABEL: TestOEQ: -; CHECK: fcmpu +; CHECK: xscmpudp ; CHECK-NEXT: beq ; CHECK: blr entry: @@ -157,7 +157,7 @@ good: define i1 @TestOGT(double %t0) { ; CHECK-LABEL: TestOGT: -; CHECK: fcmpu +; CHECK: xscmpudp ; CHECK-NEXT: bgt ; CHECK: blr entry: diff --git a/llvm/test/CodeGen/PowerPC/vsx-self-copy.ll b/llvm/test/CodeGen/PowerPC/vsx-self-copy.ll index 787ac4b7716..6a6008d2392 100644 --- a/llvm/test/CodeGen/PowerPC/vsx-self-copy.ll +++ b/llvm/test/CodeGen/PowerPC/vsx-self-copy.ll @@ -1,5 +1,5 @@ -; RUN: llc -mcpu=pwr7 -mattr=+vsx < %s | FileCheck %s -; RUN: llc -mcpu=pwr7 -mattr=+vsx -fast-isel -O0 < %s | FileCheck %s +; RUN: llc -mcpu=pwr7 -mattr=+vsx < %s -verify-machineinstrs | FileCheck %s +; RUN: llc -mcpu=pwr7 -mattr=+vsx -fast-isel -O0 < %s -verify-machineinstrs | FileCheck %s target datalayout = "E-m:e-i64:64-n32:64" target triple = "powerpc64-unknown-linux-gnu" |

