Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:43:16

0001 //===-- OverflowInstAnalysis.h - Utils to fold overflow insts ----*- C++ -*-==//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 // This file holds routines to help analyse overflow instructions
0010 // and fold them into constants or other overflow instructions
0011 //
0012 //===----------------------------------------------------------------------===//
0013 
0014 #ifndef LLVM_ANALYSIS_OVERFLOWINSTANALYSIS_H
0015 #define LLVM_ANALYSIS_OVERFLOWINSTANALYSIS_H
0016 
0017 namespace llvm {
0018 class Use;
0019 class Value;
0020 
0021 /// Match one of the patterns up to the select/logic op:
0022 ///   %Op0 = icmp ne i4 %X, 0
0023 ///   %Agg = call { i4, i1 } @llvm.[us]mul.with.overflow.i4(i4 %X, i4 %Y)
0024 ///   %Op1 = extractvalue { i4, i1 } %Agg, 1
0025 ///   %ret = select i1 %Op0, i1 %Op1, i1 false / %ret = and i1 %Op0, %Op1
0026 ///
0027 ///   %Op0 = icmp eq i4 %X, 0
0028 ///   %Agg = call { i4, i1 } @llvm.[us]mul.with.overflow.i4(i4 %X, i4 %Y)
0029 ///   %NotOp1 = extractvalue { i4, i1 } %Agg, 1
0030 ///   %Op1 = xor i1 %NotOp1, true
0031 ///   %ret = select i1 %Op0, i1 true, i1 %Op1 / %ret = or i1 %Op0, %Op1
0032 ///
0033 /// Callers are expected to align that with the operands of the select/logic.
0034 /// IsAnd is set to true if the Op0 and Op1 are used as the first pattern.
0035 /// If Op0 and Op1 match one of the patterns above, return true and fill Y's
0036 /// use.
0037 
0038 bool isCheckForZeroAndMulWithOverflow(Value *Op0, Value *Op1, bool IsAnd,
0039                                       Use *&Y);
0040 bool isCheckForZeroAndMulWithOverflow(Value *Op0, Value *Op1, bool IsAnd);
0041 } // end namespace llvm
0042 
0043 #endif