[PATCH] D57539: [InstCombine] Extra null-checking on TFE/LWE support

Michael Liao via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 1 09:22:04 PST 2019


hliao updated this revision to Diff 184771.
hliao added a comment.

test case is added


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57539/new/

https://reviews.llvm.org/D57539

Files:
  llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
  llvm/test/Transforms/InstCombine/crash.tfe.ll


Index: llvm/test/Transforms/InstCombine/crash.tfe.ll
===================================================================
--- /dev/null
+++ llvm/test/Transforms/InstCombine/crash.tfe.ll
@@ -0,0 +1,7 @@
+; RUN: opt -instcombine -S -mtriple=amdgcn-amd-amdhsa -o - %s
+define protected <4 x half> @__llvm_amdgcn_image_sample_d_1darray_v4f16_f32_f32(i32, float, float, float, float, <8 x i32>, <4 x i32>, i1 zeroext, i32, i32) local_unnamed_addr {
+  %tmp = tail call <4 x half> @llvm.amdgcn.image.sample.d.1darray.v4f16.f32.f32(i32 %0, float %1, float %2, float %3, float %4, <8 x i32> %5, <4 x i32> %6, i1 zeroext %7, i32 %8, i32 %9) #1
+  ret <4 x half> %tmp
+}
+
+declare <4 x half> @llvm.amdgcn.image.sample.d.1darray.v4f16.f32.f32(i32, float, float, float, float, <8 x i32>, <4 x i32>, i1, i32, i32)
Index: llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
===================================================================
--- llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
+++ llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
@@ -975,12 +975,11 @@
     return nullptr;
 
   // Need to change to new instruction format
-  ConstantInt *TFC = nullptr;
   bool TFELWEEnabled = false;
   if (TFCIdx > 0) {
-    TFC = dyn_cast<ConstantInt>(II->getArgOperand(TFCIdx));
-    TFELWEEnabled =    TFC->getZExtValue() & 0x1  // TFE
-                    || TFC->getZExtValue() & 0x2; // LWE
+    if (ConstantInt *TFC = dyn_cast<ConstantInt>(II->getArgOperand(TFCIdx)))
+      TFELWEEnabled =    TFC->getZExtValue() & 0x1  // TFE
+                      || TFC->getZExtValue() & 0x2; // LWE
   }
 
   if (TFELWEEnabled)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57539.184771.patch
Type: text/x-patch
Size: 1655 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190201/5db92d15/attachment.bin>


More information about the llvm-commits mailing list