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

Michael Liao via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 31 13:04:01 PST 2019


hliao created this revision.
hliao added reviewers: yaxunl, dstuttard.
Herald added subscribers: llvm-commits, hiraditya.

Need extra null-checking after ConstantInt dyn_cast.


Repository:
  rL LLVM

https://reviews.llvm.org/D57539

Files:
  llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp


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.184584.patch
Type: text/x-patch
Size: 854 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190131/4bf3f0ff/attachment.bin>


More information about the llvm-commits mailing list