R600: Use correct LoadExtType when lowering kernel arguments
authorTom Stellard <thomas.stellard@amd.com>
Tue, 23 Jul 2013 01:47:58 +0000 (01:47 +0000)
committerTom Stellard <thomas.stellard@amd.com>
Tue, 23 Jul 2013 01:47:58 +0000 (01:47 +0000)
Reviewed-by: Vincent Lejeune <vljn at ovi.com>
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186915 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/R600/R600ISelLowering.cpp
test/CodeGen/R600/short-args.ll

index 08f0c19ed8644252613e16d7745a4a1c476d359c..ac4a81c9ac576e3db79b87896795533ad5494a46 100644 (file)
@@ -1229,9 +1229,17 @@ SDValue R600TargetLowering::LowerFormalArguments(
     } else {
       ArgVT = VT;
     }
+
+    ISD::LoadExtType LoadType = ISD::EXTLOAD;
+    if (Ins[i].Flags.isZExt()) {
+      LoadType = ISD::ZEXTLOAD;
+    } else if (Ins[i].Flags.isSExt()) {
+      LoadType = ISD::SEXTLOAD;
+    }
+
     PointerType *PtrTy = PointerType::get(VT.getTypeForEVT(*DAG.getContext()),
                                                     AMDGPUAS::PARAM_I_ADDRESS);
-    SDValue Arg = DAG.getExtLoad(ISD::ZEXTLOAD, DL, VT, DAG.getRoot(),
+    SDValue Arg = DAG.getExtLoad(LoadType, DL, VT, DAG.getRoot(),
                                 DAG.getConstant(ParamOffsetBytes, MVT::i32),
                                        MachinePointerInfo(UndefValue::get(PtrTy)),
                                        ArgVT, false, false, ArgBytes);
index 1e8ba24b6d9903fd9b3474f520531ca183b3e33b..8f4dc96c7143394c64294eaa31f10ec210ef94f6 100644 (file)
@@ -21,6 +21,15 @@ entry:
   ret void
 }
 
+; CHECK: @i8_sext_arg
+; CHECK: VTX_READ_8 T{{[0-9]+\.X, T[0-9]+\.X}}
+define void @i8_sext_arg(i32 addrspace(1)* nocapture %out, i8 signext %in) nounwind {
+entry:
+  %0 = sext i8 %in to i32
+  store i32 %0, i32 addrspace(1)* %out, align 4
+  ret void
+}
+
 ; CHECK: @i16_arg
 ; CHECK: VTX_READ_16 T{{[0-9]+\.X, T[0-9]+\.X}}
 
@@ -40,3 +49,13 @@ entry:
   store i32 %0, i32 addrspace(1)* %out, align 4
   ret void
 }
+
+; CHECK: @i16_sext_arg
+; CHECK: VTX_READ_16 T{{[0-9]+\.X, T[0-9]+\.X}}
+
+define void @i16_sext_arg(i32 addrspace(1)* nocapture %out, i16 signext %in) nounwind {
+entry:
+  %0 = sext i16 %in to i32
+  store i32 %0, i32 addrspace(1)* %out, align 4
+  ret void
+}