[ValueTracking] Instruction::isBinaryOp should be used for constexprs
authorJuneyoung Lee <aqjune@gmail.com>
Sun, 26 Jul 2020 12:48:51 +0000 (21:48 +0900)
committerJuneyoung Lee <aqjune@gmail.com>
Sun, 26 Jul 2020 12:48:51 +0000 (21:48 +0900)
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

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

index 271200f..3bf09b3 100644 (file)
@@ -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;
index 3aa7785..66ec5d6 100644 (file)
@@ -139,8 +139,7 @@ define i32* @constant_expr3() {
 
 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