[llvm] r201923 - [CodeGenPrepare] Fix the check of the legality of an instruction.

Quentin Colombet qcolombet at apple.com
Fri Feb 21 17:06:41 PST 2014


Author: qcolombet
Date: Fri Feb 21 19:06:41 2014
New Revision: 201923

URL: http://llvm.org/viewvc/llvm-project?rev=201923&view=rev
Log:
[CodeGenPrepare] Fix the check of the legality of an instruction.
The API expects an ISD opcode, not an IR opcode.
Fixes a regression for R600.

Related to <rdar://problem/15519855>.

Modified:
    llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp
    llvm/trunk/test/CodeGen/R600/codegen-prepare-addrmode-sext.ll

Modified: llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp?rev=201923&r1=201922&r2=201923&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp (original)
+++ llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp Fri Feb 21 19:06:41 2014
@@ -1756,7 +1756,12 @@ AddressingModeMatcher::IsPromotionProfit
   Instruction *PromotedInst = dyn_cast<Instruction>(PromotedOperand);
   if (!PromotedInst)
     return false;
-  return TLI.isOperationLegalOrCustom(PromotedInst->getOpcode(),
+  int ISDOpcode = TLI.InstructionOpcodeToISD(PromotedInst->getOpcode());
+  // If the ISDOpcode is undefined, it was undefined before the promotion.
+  if (!ISDOpcode)
+    return true;
+  // Otherwise, check if the promoted instruction is legal or not.
+  return TLI.isOperationLegalOrCustom(ISDOpcode,
                                       EVT::getEVT(PromotedInst->getType()));
 }
 

Modified: llvm/trunk/test/CodeGen/R600/codegen-prepare-addrmode-sext.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/R600/codegen-prepare-addrmode-sext.ll?rev=201923&r1=201922&r2=201923&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/R600/codegen-prepare-addrmode-sext.ll (original)
+++ llvm/trunk/test/CodeGen/R600/codegen-prepare-addrmode-sext.ll Fri Feb 21 19:06:41 2014
@@ -1,11 +1,14 @@
-; RUN: opt -codegenprepare -S -o - %s | FileCheck %s
+; RUN: opt -codegenprepare -S -o - %s | FileCheck --check-prefix=OPT --check-prefix=FUNC %s
+; RUN: llc < %s -march=r600 -mcpu=verde -verify-machineinstrs | FileCheck --check-prefix=SI-LLC --check-prefix=FUNC %s
 
 target datalayout = "e-p:32:32-p1:64:64-p2:64:64-p3:32:32-p4:32:32-p5:64:64-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64"
 target triple = "r600--"
 
-; CHECK-LABEL: @test
-; CHECK: mul
-; CHECK-NEXT: sext
+; FUNC-LABEL: @test
+; OPT: mul nsw i32
+; OPT-NEXT: sext
+; SI-LLC: V_MUL_LO_I32
+; SI-LLC-NOT: V_MUL_HI
 define void @test(i8 addrspace(1)* nocapture readonly %in, i32 %a, i8 %b) {
 entry:
   %0 = mul nsw i32 %a, 3





More information about the llvm-commits mailing list