[PATCH] D84596: [ValueTracking] Instruction::isBinaryOp should be used for constexprs

Juneyoung Lee via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jul 26 04:53:42 PDT 2020


aqjune created this revision.
aqjune added reviewers: lebedev.ri, spatel, nikic.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.

This is a simple patch that makes canCreateUndefOrPoison use
Instruction::isBinaryOp because BinaryOperator inherits Instruction.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84596

Files:
  llvm/lib/Analysis/ValueTracking.cpp
  llvm/test/Transforms/InstSimplify/freeze.ll


Index: llvm/test/Transforms/InstSimplify/freeze.ll
===================================================================
--- llvm/test/Transforms/InstSimplify/freeze.ll
+++ llvm/test/Transforms/InstSimplify/freeze.ll
@@ -139,8 +139,7 @@
 
 define i64 @ptrdiff() {
 ; CHECK-LABEL: @ptrdiff(
-; CHECK-NEXT:    [[R:%.*]] = freeze i64 sub (i64 ptrtoint (i16* @g to i64), i64 ptrtoint (i16* @g2 to i64))
-; CHECK-NEXT:    ret i64 [[R]]
+; CHECK-NEXT:    ret i64 sub (i64 ptrtoint (i16* @g to i64), i64 ptrtoint (i16* @g2 to i64))
 ;
   %i = ptrtoint i16* @g to i64
   %i2 = ptrtoint i16* @g2 to i64
Index: llvm/lib/Analysis/ValueTracking.cpp
===================================================================
--- llvm/lib/Analysis/ValueTracking.cpp
+++ llvm/lib/Analysis/ValueTracking.cpp
@@ -4773,7 +4773,7 @@
     const auto *CE = dyn_cast<ConstantExpr>(Op);
     if (isa<CastInst>(Op) || (CE && CE->isCast()))
       return false;
-    else if (isa<BinaryOperator>(Op))
+    else if (Instruction::isBinaryOp(Opcode))
       return false;
     // Be conservative and return true.
     return true;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D84596.280717.patch
Type: text/x-patch
Size: 1094 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200726/42ee0f99/attachment.bin>


More information about the llvm-commits mailing list