[llvm] 9b5de84 - [InstCombine] Use IRBuilder to create bitcast

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 4 09:30:17 PST 2020


Author: Nikita Popov
Date: 2020-03-04T18:28:38+01:00
New Revision: 9b5de84e274fe9df971e5d32cc4ffe1ab972519d

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

LOG: [InstCombine] Use IRBuilder to create bitcast

This makes sure that the constant expression bitcast goes through
target-dependent constant folding, and thus avoids an additional
iteration of InstCombine.

Added: 
    

Modified: 
    llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
    llvm/test/Transforms/InstCombine/icmp-xor-signbit.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
index fc4d438c42b2..52edda6af1ef 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
@@ -2151,7 +2151,7 @@ static Instruction *foldBitCastBitwiseLogic(BitCastInst &BitCast,
   if (match(BO->getOperand(1), m_Constant(C))) {
     // bitcast (logic X, C) --> logic (bitcast X, C')
     Value *CastedOp0 = Builder.CreateBitCast(BO->getOperand(0), DestTy);
-    Value *CastedC = ConstantExpr::getBitCast(C, DestTy);
+    Value *CastedC = Builder.CreateBitCast(C, DestTy);
     return BinaryOperator::Create(BO->getOpcode(), CastedOp0, CastedC);
   }
 

diff  --git a/llvm/test/Transforms/InstCombine/icmp-xor-signbit.ll b/llvm/test/Transforms/InstCombine/icmp-xor-signbit.ll
index dab9b5e9fefe..ac5394351205 100644
--- a/llvm/test/Transforms/InstCombine/icmp-xor-signbit.ll
+++ b/llvm/test/Transforms/InstCombine/icmp-xor-signbit.ll
@@ -1,5 +1,5 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
-; RUN: opt < %s -instcombine -S | FileCheck %s
+; RUN: opt < %s -instcombine -instcombine-infinite-loop-threshold=2 -S | FileCheck %s
 
 ; icmp u/s (a ^ signmask), (b ^ signmask) --> icmp s/u a, b
 


        


More information about the llvm-commits mailing list