[llvm] 9f07421 - [ValueTracking] Instruction::isBinaryOp should be used for constexprs

Juneyoung Lee via llvm-commits llvm-commits at lists.llvm.org
Sun Jul 26 05:49:17 PDT 2020


Author: Juneyoung Lee
Date: 2020-07-26T21:48:51+09:00
New Revision: 9f074214b7a3bc9d88caadbf7bd6116305977a4e

URL: https://github.com/llvm/llvm-project/commit/9f074214b7a3bc9d88caadbf7bd6116305977a4e
DIFF: https://github.com/llvm/llvm-project/commit/9f074214b7a3bc9d88caadbf7bd6116305977a4e.diff

LOG: [ValueTracking] Instruction::isBinaryOp should be used for constexprs

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

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D84596

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index 271200f7030a..3bf09b30b2f9 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -4773,7 +4773,7 @@ static bool canCreateUndefOrPoison(const Operator *Op, bool PoisonOnly) {
     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;

diff  --git a/llvm/test/Transforms/InstSimplify/freeze.ll b/llvm/test/Transforms/InstSimplify/freeze.ll
index 3aa77854f602..66ec5d61a3c1 100644
--- a/llvm/test/Transforms/InstSimplify/freeze.ll
+++ b/llvm/test/Transforms/InstSimplify/freeze.ll
@@ -139,8 +139,7 @@ define i32* @constant_expr3() {
 
 define i64 @ptr
diff () {
 ; CHECK-LABEL: @ptr
diff (
-; 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


        


More information about the llvm-commits mailing list