mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-04-02 15:51:54 +00:00
[ConstProp] Remove ConstantPropagation
As discussed in http://lists.llvm.org/pipermail/llvm-dev/2020-July/143801.html. Currently no users outside of unit tests. Replace all instances in tests of -constprop with -instsimplify. Notable changes in tests: * vscale.ll - @llvm.sadd.sat.nxv16i8 is evaluated by instsimplify, use a fake intrinsic instead * InsertElement.ll - insertelement undef is removed by instsimplify in @insertelement_undef llvm/test/Transforms/ConstProp moved to llvm/test/Transforms/InstSimplify/ConstProp Reviewed By: lattner, nikic Differential Revision: https://reviews.llvm.org/D85159
This commit is contained in:
parent
47ba73f241
commit
d74ec65308
@ -80,7 +80,6 @@ func TestFactorial(t *testing.T) {
|
||||
pass := NewPassManager()
|
||||
defer pass.Dispose()
|
||||
|
||||
pass.AddConstantPropagationPass()
|
||||
pass.AddInstructionCombiningPass()
|
||||
pass.AddPromoteMemoryToRegisterPass()
|
||||
pass.AddGVNPass()
|
||||
|
@ -40,6 +40,5 @@ func (pm PassManager) AddScalarReplAggregatesPassWithThreshold(threshold int) {
|
||||
}
|
||||
func (pm PassManager) AddSimplifyLibCallsPass() { C.LLVMAddSimplifyLibCallsPass(pm.C) }
|
||||
func (pm PassManager) AddTailCallEliminationPass() { C.LLVMAddTailCallEliminationPass(pm.C) }
|
||||
func (pm PassManager) AddConstantPropagationPass() { C.LLVMAddConstantPropagationPass(pm.C) }
|
||||
func (pm PassManager) AddDemoteMemoryToRegisterPass() { C.LLVMAddDemoteMemoryToRegisterPass(pm.C) }
|
||||
func (pm PassManager) AddVerifierPass() { C.LLVMAddVerifierPass(pm.C) }
|
||||
|
@ -161,11 +161,6 @@ external add_tail_call_elimination
|
||||
: [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit
|
||||
= "llvm_add_tail_call_elimination"
|
||||
|
||||
(** See the [llvm::createConstantPropagationPass] function. *)
|
||||
external add_constant_propagation
|
||||
: [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit
|
||||
= "llvm_add_constant_propagation"
|
||||
|
||||
(** See the [llvm::createDemoteMemoryToRegisterPass] function. *)
|
||||
external add_memory_to_register_demotion
|
||||
: [< Llvm.PassManager.any ] Llvm.PassManager.t -> unit
|
||||
|
@ -200,12 +200,6 @@ CAMLprim value llvm_add_tail_call_elimination(LLVMPassManagerRef PM) {
|
||||
return Val_unit;
|
||||
}
|
||||
|
||||
/* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */
|
||||
CAMLprim value llvm_add_constant_propagation(LLVMPassManagerRef PM) {
|
||||
LLVMAddConstantPropagationPass(PM);
|
||||
return Val_unit;
|
||||
}
|
||||
|
||||
/* [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */
|
||||
CAMLprim value llvm_add_demote_memory_to_register(LLVMPassManagerRef PM) {
|
||||
LLVMAddDemoteMemoryToRegisterPass(PM);
|
||||
|
@ -475,7 +475,7 @@ Parsing a list of options
|
||||
Now that we have the standard run-of-the-mill argument types out of the way,
|
||||
lets get a little wild and crazy. Lets say that we want our optimizer to accept
|
||||
a **list** of optimizations to perform, allowing duplicates. For example, we
|
||||
might want to run: "``compiler -dce -constprop -inline -dce -strip``". In this
|
||||
might want to run: "``compiler -dce -instsimplify -inline -dce -strip``". In this
|
||||
case, the order of the arguments and the number of appearances is very
|
||||
important. This is what the "``cl::list``" template is for. First, start by
|
||||
defining an enum of the optimizations that you would like to perform:
|
||||
@ -484,7 +484,7 @@ defining an enum of the optimizations that you would like to perform:
|
||||
|
||||
enum Opts {
|
||||
// 'inline' is a C++ keyword, so name it 'inlining'
|
||||
dce, constprop, inlining, strip
|
||||
dce, instsimplify, inlining, strip
|
||||
};
|
||||
|
||||
Then define your "``cl::list``" variable:
|
||||
@ -494,7 +494,7 @@ Then define your "``cl::list``" variable:
|
||||
cl::list<Opts> OptimizationList(cl::desc("Available Optimizations:"),
|
||||
cl::values(
|
||||
clEnumVal(dce , "Dead Code Elimination"),
|
||||
clEnumVal(constprop , "Constant Propagation"),
|
||||
clEnumVal(instsimplify , "Instruction Simplification"),
|
||||
clEnumValN(inlining, "inline", "Procedure Integration"),
|
||||
clEnumVal(strip , "Strip Symbols")));
|
||||
|
||||
@ -553,16 +553,16 @@ Reworking the above list example, we could replace `cl::list`_ with `cl::bits`_:
|
||||
cl::bits<Opts> OptimizationBits(cl::desc("Available Optimizations:"),
|
||||
cl::values(
|
||||
clEnumVal(dce , "Dead Code Elimination"),
|
||||
clEnumVal(constprop , "Constant Propagation"),
|
||||
clEnumVal(instsimplify , "Instruction Simplification"),
|
||||
clEnumValN(inlining, "inline", "Procedure Integration"),
|
||||
clEnumVal(strip , "Strip Symbols")));
|
||||
|
||||
To test to see if ``constprop`` was specified, we can use the ``cl:bits::isSet``
|
||||
To test to see if ``instsimplify`` was specified, we can use the ``cl:bits::isSet``
|
||||
function:
|
||||
|
||||
.. code-block:: c++
|
||||
|
||||
if (OptimizationBits.isSet(constprop)) {
|
||||
if (OptimizationBits.isSet(instsimplify)) {
|
||||
...
|
||||
}
|
||||
|
||||
|
@ -460,27 +460,6 @@ shared. This is useful because some passes (i.e., TraceValues) insert a lot of
|
||||
string constants into the program, regardless of whether or not an existing
|
||||
string is available.
|
||||
|
||||
``-constprop``: Simple constant propagation
|
||||
-------------------------------------------
|
||||
|
||||
This pass implements constant propagation and merging. It looks for
|
||||
instructions involving only constant operands and replaces them with a constant
|
||||
value instead of an instruction. For example:
|
||||
|
||||
.. code-block:: llvm
|
||||
|
||||
add i32 1, 2
|
||||
|
||||
becomes
|
||||
|
||||
.. code-block:: llvm
|
||||
|
||||
i32 3
|
||||
|
||||
NOTE: this pass has a habit of making definitions be dead. It is a good idea
|
||||
to run a :ref:`Dead Instruction Elimination <passes-die>` pass sometime after
|
||||
running this pass.
|
||||
|
||||
.. _passes-dce:
|
||||
|
||||
``-dce``: Dead Code Elimination
|
||||
|
@ -125,9 +125,6 @@ void LLVMAddSimplifyLibCallsPass(LLVMPassManagerRef PM);
|
||||
/** See llvm::createTailCallEliminationPass function. */
|
||||
void LLVMAddTailCallEliminationPass(LLVMPassManagerRef PM);
|
||||
|
||||
/** See llvm::createConstantPropagationPass function. */
|
||||
void LLVMAddConstantPropagationPass(LLVMPassManagerRef PM);
|
||||
|
||||
/** See llvm::demotePromoteMemoryToRegisterPass function. */
|
||||
void LLVMAddDemoteMemoryToRegisterPass(LLVMPassManagerRef PM);
|
||||
|
||||
|
@ -113,7 +113,6 @@ void initializeCalledValuePropagationLegacyPassPass(PassRegistry &);
|
||||
void initializeCodeGenPreparePass(PassRegistry&);
|
||||
void initializeConstantHoistingLegacyPassPass(PassRegistry&);
|
||||
void initializeConstantMergeLegacyPassPass(PassRegistry&);
|
||||
void initializeConstantPropagationPass(PassRegistry&);
|
||||
void initializeControlHeightReductionLegacyPassPass(PassRegistry&);
|
||||
void initializeCorrelatedValuePropagationPass(PassRegistry&);
|
||||
void initializeCostModelAnalysisPass(PassRegistry&);
|
||||
|
@ -89,7 +89,6 @@ namespace {
|
||||
(void) llvm::createLibCallsShrinkWrapPass();
|
||||
(void) llvm::createCalledValuePropagationPass();
|
||||
(void) llvm::createConstantMergePass();
|
||||
(void) llvm::createConstantPropagationPass();
|
||||
(void) llvm::createControlHeightReductionLegacyPass();
|
||||
(void) llvm::createCostModelAnalysisPass();
|
||||
(void) llvm::createDeadArgEliminationPass();
|
||||
|
@ -24,12 +24,6 @@ class FunctionPass;
|
||||
class ModulePass;
|
||||
class Pass;
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// ConstantPropagation - A worklist driven constant propagation pass
|
||||
//
|
||||
FunctionPass *createConstantPropagationPass();
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// AlignmentFromAssumptions - Use assume intrinsics to set load/store
|
||||
|
@ -4,7 +4,6 @@ add_llvm_component_library(LLVMScalarOpts
|
||||
BDCE.cpp
|
||||
CallSiteSplitting.cpp
|
||||
ConstantHoisting.cpp
|
||||
ConstantProp.cpp
|
||||
CorrelatedValuePropagation.cpp
|
||||
DCE.cpp
|
||||
DeadStoreElimination.cpp
|
||||
|
@ -1,121 +0,0 @@
|
||||
//===- ConstantProp.cpp - Code to perform Simple Constant Propagation -----===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file implements constant propagation and merging:
|
||||
//
|
||||
// Specifically, this:
|
||||
// * Converts instructions like "add int 1, 2" into 3
|
||||
//
|
||||
// Notice that:
|
||||
// * This pass has a habit of making definitions be dead. It is a good idea
|
||||
// to run a DIE pass sometime after running this pass.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "llvm/ADT/SmallPtrSet.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/Statistic.h"
|
||||
#include "llvm/Analysis/ConstantFolding.h"
|
||||
#include "llvm/Analysis/TargetLibraryInfo.h"
|
||||
#include "llvm/IR/Constant.h"
|
||||
#include "llvm/IR/InstIterator.h"
|
||||
#include "llvm/IR/Instruction.h"
|
||||
#include "llvm/InitializePasses.h"
|
||||
#include "llvm/Pass.h"
|
||||
#include "llvm/Support/DebugCounter.h"
|
||||
#include "llvm/Transforms/Scalar.h"
|
||||
#include "llvm/Transforms/Utils/Local.h"
|
||||
using namespace llvm;
|
||||
|
||||
#define DEBUG_TYPE "constprop"
|
||||
|
||||
STATISTIC(NumInstKilled, "Number of instructions killed");
|
||||
DEBUG_COUNTER(CPCounter, "constprop-transform",
|
||||
"Controls which instructions are killed");
|
||||
|
||||
namespace {
|
||||
struct ConstantPropagation : public FunctionPass {
|
||||
static char ID; // Pass identification, replacement for typeid
|
||||
ConstantPropagation() : FunctionPass(ID) {
|
||||
initializeConstantPropagationPass(*PassRegistry::getPassRegistry());
|
||||
}
|
||||
|
||||
bool runOnFunction(Function &F) override;
|
||||
|
||||
void getAnalysisUsage(AnalysisUsage &AU) const override {
|
||||
AU.setPreservesCFG();
|
||||
AU.addRequired<TargetLibraryInfoWrapperPass>();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
char ConstantPropagation::ID = 0;
|
||||
INITIALIZE_PASS_BEGIN(ConstantPropagation, "constprop",
|
||||
"Simple constant propagation", false, false)
|
||||
INITIALIZE_PASS_DEPENDENCY(TargetLibraryInfoWrapperPass)
|
||||
INITIALIZE_PASS_END(ConstantPropagation, "constprop",
|
||||
"Simple constant propagation", false, false)
|
||||
|
||||
FunctionPass *llvm::createConstantPropagationPass() {
|
||||
return new ConstantPropagation();
|
||||
}
|
||||
|
||||
bool ConstantPropagation::runOnFunction(Function &F) {
|
||||
if (skipFunction(F))
|
||||
return false;
|
||||
|
||||
// Initialize the worklist to all of the instructions ready to process...
|
||||
SmallPtrSet<Instruction *, 16> WorkList;
|
||||
// The SmallVector of WorkList ensures that we do iteration at stable order.
|
||||
// We use two containers rather than one SetVector, since remove is
|
||||
// linear-time, and we don't care enough to remove from Vec.
|
||||
SmallVector<Instruction *, 16> WorkListVec;
|
||||
for (Instruction &I : instructions(&F)) {
|
||||
WorkList.insert(&I);
|
||||
WorkListVec.push_back(&I);
|
||||
}
|
||||
|
||||
bool Changed = false;
|
||||
const DataLayout &DL = F.getParent()->getDataLayout();
|
||||
TargetLibraryInfo *TLI =
|
||||
&getAnalysis<TargetLibraryInfoWrapperPass>().getTLI(F);
|
||||
|
||||
while (!WorkList.empty()) {
|
||||
SmallVector<Instruction*, 16> NewWorkListVec;
|
||||
for (auto *I : WorkListVec) {
|
||||
WorkList.erase(I); // Remove element from the worklist...
|
||||
|
||||
if (!I->use_empty()) // Don't muck with dead instructions...
|
||||
if (Constant *C = ConstantFoldInstruction(I, DL, TLI)) {
|
||||
if (!DebugCounter::shouldExecute(CPCounter))
|
||||
continue;
|
||||
|
||||
// Add all of the users of this instruction to the worklist, they might
|
||||
// be constant propagatable now...
|
||||
for (User *U : I->users()) {
|
||||
// If user not in the set, then add it to the vector.
|
||||
if (WorkList.insert(cast<Instruction>(U)).second)
|
||||
NewWorkListVec.push_back(cast<Instruction>(U));
|
||||
}
|
||||
|
||||
// Replace all of the uses of a variable with uses of the constant.
|
||||
I->replaceAllUsesWith(C);
|
||||
|
||||
if (isInstructionTriviallyDead(I, TLI)) {
|
||||
I->eraseFromParent();
|
||||
++NumInstKilled;
|
||||
}
|
||||
|
||||
// We made a change to the function...
|
||||
Changed = true;
|
||||
}
|
||||
}
|
||||
WorkListVec = std::move(NewWorkListVec);
|
||||
}
|
||||
return Changed;
|
||||
}
|
@ -38,7 +38,6 @@ void llvm::initializeScalarOpts(PassRegistry &Registry) {
|
||||
initializeAlignmentFromAssumptionsPass(Registry);
|
||||
initializeCallSiteSplittingLegacyPassPass(Registry);
|
||||
initializeConstantHoistingLegacyPassPass(Registry);
|
||||
initializeConstantPropagationPass(Registry);
|
||||
initializeCorrelatedValuePropagationPass(Registry);
|
||||
initializeDCELegacyPassPass(Registry);
|
||||
initializeDeadInstEliminationPass(Registry);
|
||||
@ -248,10 +247,6 @@ void LLVMAddTailCallEliminationPass(LLVMPassManagerRef PM) {
|
||||
unwrap(PM)->add(createTailCallEliminationPass());
|
||||
}
|
||||
|
||||
void LLVMAddConstantPropagationPass(LLVMPassManagerRef PM) {
|
||||
unwrap(PM)->add(createConstantPropagationPass());
|
||||
}
|
||||
|
||||
void LLVMAddDemoteMemoryToRegisterPass(LLVMPassManagerRef PM) {
|
||||
unwrap(PM)->add(createDemoteRegisterToMemoryPass());
|
||||
}
|
||||
|
@ -5,8 +5,8 @@
|
||||
; of the bug that was causing the Olden Health benchmark to output incorrect
|
||||
; results!
|
||||
;
|
||||
; RUN: opt -constprop -S > %t.1 < %s
|
||||
; RUN: llvm-as < %s | llvm-dis | llvm-as | opt -constprop | \
|
||||
; RUN: opt -instsimplify -S > %t.1 < %s
|
||||
; RUN: llvm-as < %s | llvm-dis | llvm-as | opt -instsimplify | \
|
||||
; RUN: llvm-dis > %t.2
|
||||
; RUN: diff %t.1 %t.2
|
||||
; RUN: verify-uselistorder %s
|
||||
|
@ -1,4 +1,4 @@
|
||||
; RUN: opt < %s -constprop | llvm-dis -disable-output
|
||||
; RUN: opt < %s -instsimplify | llvm-dis -disable-output
|
||||
; RUN: verify-uselistorder < %s
|
||||
; PR3465
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
;
|
||||
; Fixed by adding new arguments to ConstantFoldTerminator
|
||||
;
|
||||
; RUN: opt < %s -constprop
|
||||
; RUN: opt < %s -instsimplify
|
||||
|
||||
define void @build_tree(i32 %ml) {
|
||||
; <label>:0
|
@ -1,6 +1,6 @@
|
||||
; Make sure that the constant propogator doesn't divide by zero!
|
||||
;
|
||||
; RUN: opt < %s -constprop
|
||||
; RUN: opt < %s -instsimplify
|
||||
;
|
||||
|
||||
define i32 @test() {
|
@ -4,7 +4,7 @@
|
||||
|
||||
; Fix #2: The unary not instruction now no longer exists. Change to xor.
|
||||
|
||||
; RUN: opt < %s -constprop -S | \
|
||||
; RUN: opt < %s -instsimplify -S | \
|
||||
; RUN: not grep "i32 0"
|
||||
|
||||
define i32 @test1() {
|
@ -1,6 +1,6 @@
|
||||
; SetCC on boolean values was not implemented!
|
||||
|
||||
; RUN: opt < %s -constprop -die -S | \
|
||||
; RUN: opt < %s -instsimplify -die -S | \
|
||||
; RUN: not grep set
|
||||
|
||||
define i1 @test1() {
|
@ -1,6 +1,6 @@
|
||||
; Make sure that the constant propagator doesn't cause a sigfpe
|
||||
;
|
||||
; RUN: opt < %s -constprop
|
||||
; RUN: opt < %s -instsimplify
|
||||
;
|
||||
|
||||
define i32 @test() {
|
@ -1,4 +1,4 @@
|
||||
; RUN: opt < %s -constprop -S | \
|
||||
; RUN: opt < %s -instsimplify -S | \
|
||||
; RUN: not grep "ret i1 false"
|
||||
|
||||
@b = external global [2 x { }] ; <[2 x { }]*> [#uses=2]
|
@ -1,6 +1,6 @@
|
||||
; RUN: opt < %s -constprop -S | \
|
||||
; RUN: opt < %s -instsimplify -S | \
|
||||
; RUN: grep "i32 -1"
|
||||
; RUN: opt < %s -constprop -S | \
|
||||
; RUN: opt < %s -instsimplify -S | \
|
||||
; RUN: not grep zeroinitializer
|
||||
|
||||
define <4 x i32> @test() {
|
@ -1,6 +1,6 @@
|
||||
; RUN: opt < %s -constprop -S | \
|
||||
; RUN: opt < %s -instsimplify -S | \
|
||||
; RUN: grep "ret i32 -1"
|
||||
; RUN: opt < %s -constprop -S | \
|
||||
; RUN: opt < %s -instsimplify -S | \
|
||||
; RUN: grep "ret i32 1"
|
||||
|
||||
define i32 @test1() {
|
@ -1,4 +1,4 @@
|
||||
; RUN: opt < %s -constprop -S | grep 1065353216
|
||||
; RUN: opt < %s -instsimplify -S | grep 1065353216
|
||||
|
||||
define i32 @test() {
|
||||
%A = bitcast float 1.000000e+00 to i32 ; <i32> [#uses=1]
|
@ -1,4 +1,4 @@
|
||||
; RUN: opt < %s -constprop -disable-output
|
||||
; RUN: opt < %s -instsimplify -disable-output
|
||||
; PR2529
|
||||
define <4 x i1> @test1(i32 %argc, i8** %argv) {
|
||||
entry:
|
@ -1,4 +1,4 @@
|
||||
; RUN: opt < %s -constprop | llvm-dis
|
||||
; RUN: opt < %s -instsimplify | llvm-dis
|
||||
; PR4848
|
||||
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128"
|
||||
target triple = "x86_64-unknown-linux-gnu"
|
@ -1,5 +1,5 @@
|
||||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
||||
; RUN: opt < %s -constprop -S | FileCheck %s
|
||||
; RUN: opt < %s -instsimplify -S | FileCheck %s
|
||||
|
||||
define i32 @test1() {
|
||||
; CHECK-LABEL: @test1(
|
||||
@ -25,7 +25,6 @@ define <4 x i64> @insertelement() {
|
||||
|
||||
define <4 x i64> @insertelement_undef() {
|
||||
; CHECK-LABEL: @insertelement_undef(
|
||||
; CHECK-NEXT: [[VEC4:%.*]] = insertelement <4 x i64> <i64 -1, i64 -2, i64 -3, i64 undef>, i64 -4, i32 3
|
||||
; CHECK-NEXT: ret <4 x i64> undef
|
||||
;
|
||||
%vec1 = insertelement <4 x i64> undef, i64 -1, i32 0
|
@ -1,5 +1,5 @@
|
||||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
||||
; RUN: opt < %s -constprop -S | FileCheck %s
|
||||
; RUN: opt < %s -instsimplify -S | FileCheck %s
|
||||
|
||||
declare i8 @llvm.abs.i8(i8, i1)
|
||||
declare <8 x i8> @llvm.abs.v8i8(<8 x i8>, i1)
|
@ -1,4 +1,4 @@
|
||||
; RUN: opt < %s -constprop -S | FileCheck %s
|
||||
; RUN: opt < %s -instsimplify -S | FileCheck %s
|
||||
; REQUIRES: x86-registered-target
|
||||
|
||||
define i1 @test_avx512_cvts_exact() nounwind readnone {
|
@ -1,4 +1,4 @@
|
||||
; RUN: opt < %s -constprop -die -S | FileCheck %s
|
||||
; RUN: opt < %s -instsimplify -die -S | FileCheck %s
|
||||
|
||||
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
|
||||
target triple = "x86_64-apple-macosx10.7.2"
|
@ -1,5 +1,5 @@
|
||||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
||||
; RUN: opt -constprop -S %s | FileCheck %s
|
||||
; RUN: opt -instsimplify -S %s | FileCheck %s
|
||||
|
||||
define i32 @and1() {
|
||||
; CHECK-LABEL: @and1(
|
@ -1,5 +1,5 @@
|
||||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
||||
; RUN: opt < %s -constprop -S | FileCheck %s
|
||||
; RUN: opt < %s -instsimplify -S | FileCheck %s
|
||||
; PR2165
|
||||
|
||||
define <1 x i64> @test1() {
|
@ -1,5 +1,5 @@
|
||||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
||||
; RUN: opt < %s -constprop -S | FileCheck %s
|
||||
; RUN: opt < %s -instsimplify -S | FileCheck %s
|
||||
|
||||
declare i31 @llvm.ctpop.i31(i31 %val)
|
||||
declare i32 @llvm.cttz.i32(i32 %val, i1)
|
@ -1,6 +1,6 @@
|
||||
; bswap should be constant folded when it is passed a constant argument
|
||||
|
||||
; RUN: opt < %s -constprop -S | FileCheck %s
|
||||
; RUN: opt < %s -instsimplify -S | FileCheck %s
|
||||
|
||||
declare i16 @llvm.bswap.i16(i16)
|
||||
|
@ -1,6 +1,6 @@
|
||||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
||||
; RUN: opt < %s -constprop -S | FileCheck %s
|
||||
; RUN: opt < %s -constprop -S -mtriple=unknown-unknown-linux-musl | FileCheck -check-prefix=MUSL %s
|
||||
; RUN: opt < %s -instsimplify -S | FileCheck %s
|
||||
; RUN: opt < %s -instsimplify -S -mtriple=unknown-unknown-linux-musl | FileCheck -check-prefix=MUSL %s
|
||||
|
||||
; Test to verify constant folding can occur when math routines are mapped
|
||||
; to the __<func>_finite versions of functions due to __FINITE_MATH_ONLY__
|
@ -1,5 +1,5 @@
|
||||
; RUN: opt < %s -constprop -S | FileCheck %s
|
||||
; RUN: opt < %s -constprop -disable-simplify-libcalls -S | FileCheck %s --check-prefix=FNOBUILTIN
|
||||
; RUN: opt < %s -instsimplify -S | FileCheck %s
|
||||
; RUN: opt < %s -instsimplify -disable-simplify-libcalls -S | FileCheck %s --check-prefix=FNOBUILTIN
|
||||
|
||||
declare double @acos(double) readnone nounwind
|
||||
declare double @asin(double) readnone nounwind
|
@ -1,32 +1,32 @@
|
||||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
||||
; RUN: opt < %s -instsimplify -S | FileCheck %s
|
||||
|
||||
; Test constant fold of constant expression GEP used by ptrtoint (the
|
||||
; "offsetof-like expression" case).
|
||||
; This used to hit an assert due to not supporting vectors in
|
||||
; llvm::ConstantFoldCastInstruction when handling ptrtoint.
|
||||
define <2 x i16> @test1() {
|
||||
; CHECK-LABEL: @test1(
|
||||
; CHECK-NEXT: entry:
|
||||
; CHECK-NEXT: ret <2 x i16> ptrtoint (<2 x i32*> getelementptr ([10 x i32], [10 x i32]* null, <2 x i64> zeroinitializer, <2 x i64> <i64 5, i64 7>) to <2 x i16>)
|
||||
;
|
||||
entry:
|
||||
%gep = getelementptr inbounds [10 x i32], [10 x i32]* null, i16 0, <2 x i16> <i16 5, i16 7>
|
||||
%vec = ptrtoint <2 x i32*> %gep to <2 x i16>
|
||||
ret <2 x i16> %vec
|
||||
}
|
||||
|
||||
; Test constant fold of constant expression GEP used by ptrtoint (the
|
||||
; "sizeof-like expression" case).
|
||||
; This used to hit an assert due to not supporting vectors in
|
||||
; llvm::ConstantFoldCastInstruction when handling ptrtoint.
|
||||
define <2 x i16> @test2() {
|
||||
; CHECK-LABEL: @test2(
|
||||
; CHECK-NEXT: entry:
|
||||
; CHECK-NEXT: ret <2 x i16> ptrtoint (<2 x i32*> getelementptr (i32, i32* null, <2 x i64> <i64 5, i64 7>) to <2 x i16>)
|
||||
;
|
||||
entry:
|
||||
%gep = getelementptr i32, i32* null, <2 x i16> <i16 5, i16 7>
|
||||
%vec = ptrtoint <2 x i32*> %gep to <2 x i16>
|
||||
ret <2 x i16> %vec
|
||||
}
|
||||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
||||
; RUN: opt < %s -instsimplify -S | FileCheck %s
|
||||
|
||||
; Test constant fold of constant expression GEP used by ptrtoint (the
|
||||
; "offsetof-like expression" case).
|
||||
; This used to hit an assert due to not supporting vectors in
|
||||
; llvm::ConstantFoldCastInstruction when handling ptrtoint.
|
||||
define <2 x i16> @test1() {
|
||||
; CHECK-LABEL: @test1(
|
||||
; CHECK-NEXT: entry:
|
||||
; CHECK-NEXT: ret <2 x i16> ptrtoint (<2 x i32*> getelementptr ([10 x i32], [10 x i32]* null, <2 x i64> zeroinitializer, <2 x i64> <i64 5, i64 7>) to <2 x i16>)
|
||||
;
|
||||
entry:
|
||||
%gep = getelementptr inbounds [10 x i32], [10 x i32]* null, i16 0, <2 x i16> <i16 5, i16 7>
|
||||
%vec = ptrtoint <2 x i32*> %gep to <2 x i16>
|
||||
ret <2 x i16> %vec
|
||||
}
|
||||
|
||||
; Test constant fold of constant expression GEP used by ptrtoint (the
|
||||
; "sizeof-like expression" case).
|
||||
; This used to hit an assert due to not supporting vectors in
|
||||
; llvm::ConstantFoldCastInstruction when handling ptrtoint.
|
||||
define <2 x i16> @test2() {
|
||||
; CHECK-LABEL: @test2(
|
||||
; CHECK-NEXT: entry:
|
||||
; CHECK-NEXT: ret <2 x i16> ptrtoint (<2 x i32*> getelementptr (i32, i32* null, <2 x i64> <i64 5, i64 7>) to <2 x i16>)
|
||||
;
|
||||
entry:
|
||||
%gep = getelementptr i32, i32* null, <2 x i16> <i16 5, i16 7>
|
||||
%vec = ptrtoint <2 x i32*> %gep to <2 x i16>
|
||||
ret <2 x i16> %vec
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
; RUN: opt < %s -constprop -S | FileCheck %s
|
||||
; RUN: opt < %s -instsimplify -S | FileCheck %s
|
||||
|
||||
; Overflow on a float to int or int to float conversion is undefined (PR21130).
|
||||
|
@ -1,4 +1,4 @@
|
||||
; RUN: opt -constprop -S < %s | FileCheck %s
|
||||
; RUN: opt -instsimplify -S < %s | FileCheck %s
|
||||
|
||||
; Verify that we don't crash with an assertion failure when constant folding
|
||||
; a call to intrinsic 'convert.from.fp16' if the return type is not 'float'.
|
@ -1,5 +1,5 @@
|
||||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
||||
; RUN: opt -S -constprop < %s | FileCheck %s
|
||||
; RUN: opt -S -instsimplify < %s | FileCheck %s
|
||||
|
||||
declare float @llvm.copysign.f32(float, float)
|
||||
declare double @llvm.copysign.f64(double, double)
|
@ -1,4 +1,4 @@
|
||||
; RUN: opt < %s -constprop -S | FileCheck %s
|
||||
; RUN: opt < %s -instsimplify -S | FileCheck %s
|
||||
|
||||
%struct = type { i32, [4 x i8] }
|
||||
|
@ -1,4 +1,4 @@
|
||||
; RUN: opt < %s -constprop -S | FileCheck %s
|
||||
; RUN: opt < %s -instsimplify -S | FileCheck %s
|
||||
|
||||
define i32* @test1() {
|
||||
%X = inttoptr i64 0 to i32* ; <i32*> [#uses=1]
|
@ -1,5 +1,5 @@
|
||||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
||||
; RUN: opt -constprop -S < %s | FileCheck %s
|
||||
; RUN: opt -instsimplify -S < %s | FileCheck %s
|
||||
|
||||
; Fixes PR20832
|
||||
; Make sure that we correctly fold a fused multiply-add where operands
|
@ -1,5 +1,5 @@
|
||||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
||||
; RUN: opt < %s -constprop -S | FileCheck %s
|
||||
; RUN: opt < %s -instsimplify -S | FileCheck %s
|
||||
|
||||
define float @fneg_constant() {
|
||||
; CHECK-LABEL: @fneg_constant(
|
@ -1,5 +1,5 @@
|
||||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
||||
; RUN: opt < %s -constprop -S | FileCheck %s
|
||||
; RUN: opt < %s -instsimplify -S | FileCheck %s
|
||||
|
||||
; Constant folding - undef undef.
|
||||
|
@ -1,5 +1,5 @@
|
||||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
||||
; RUN: opt < %s -constprop -S | FileCheck %s
|
||||
; RUN: opt < %s -instsimplify -S | FileCheck %s
|
||||
|
||||
@g = external global i16, align 1
|
||||
@g2 = external global i16, align 1
|
@ -1,5 +1,5 @@
|
||||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
||||
; RUN: opt < %s -constprop -S -o - | FileCheck %s
|
||||
; RUN: opt < %s -instsimplify -S -o - | FileCheck %s
|
||||
|
||||
declare i32 @llvm.fshl.i32(i32, i32, i32)
|
||||
declare i32 @llvm.fshr.i32(i32, i32, i32)
|
@ -1,17 +1,17 @@
|
||||
; RUN: opt -instcombine -S -o - %s | FileCheck %s
|
||||
; Test that we don't replace an alias with its aliasee when simplifying GEPs.
|
||||
; In this test case the transformation is invalid because it replaces the
|
||||
; reference to the symbol "b" (which refers to whichever instance of "b"
|
||||
; was chosen by the linker) with a reference to "a" (which refers to the
|
||||
; specific instance of "b" in this module).
|
||||
|
||||
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
|
||||
target triple = "x86_64-unknown-linux-gnu"
|
||||
|
||||
@a = internal global [3 x i8*] zeroinitializer
|
||||
@b = linkonce_odr alias [3 x i8*], [3 x i8*]* @a
|
||||
|
||||
define i8** @f() {
|
||||
; CHECK: ret i8** getelementptr ([3 x i8*], [3 x i8*]* @b, i64 0, i64 1)
|
||||
ret i8** getelementptr ([3 x i8*], [3 x i8*]* @b, i64 0, i64 1)
|
||||
}
|
||||
; RUN: opt -instcombine -S -o - %s | FileCheck %s
|
||||
; Test that we don't replace an alias with its aliasee when simplifying GEPs.
|
||||
; In this test case the transformation is invalid because it replaces the
|
||||
; reference to the symbol "b" (which refers to whichever instance of "b"
|
||||
; was chosen by the linker) with a reference to "a" (which refers to the
|
||||
; specific instance of "b" in this module).
|
||||
|
||||
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
|
||||
target triple = "x86_64-unknown-linux-gnu"
|
||||
|
||||
@a = internal global [3 x i8*] zeroinitializer
|
||||
@b = linkonce_odr alias [3 x i8*], [3 x i8*]* @a
|
||||
|
||||
define i8** @f() {
|
||||
; CHECK: ret i8** getelementptr ([3 x i8*], [3 x i8*]* @b, i64 0, i64 1)
|
||||
ret i8** getelementptr ([3 x i8*], [3 x i8*]* @b, i64 0, i64 1)
|
||||
}
|
@ -1,52 +1,52 @@
|
||||
; RUN: opt -gvn -S -o - %s | FileCheck %s
|
||||
; RUN: opt -newgvn -S -o - %s | FileCheck %s
|
||||
; Test that the constantfolding getelementptr computation results in
|
||||
; j[5][4][1] (j+239)
|
||||
; and not [1][4][4][1] (#449) which is an incorrect out-of-range error
|
||||
target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
|
||||
target triple = "armv7-none-eabi"
|
||||
|
||||
@f = local_unnamed_addr global i32 2, align 4
|
||||
@t6 = local_unnamed_addr global i32 1, align 4
|
||||
@j = local_unnamed_addr global [6 x [6 x [7 x i8]]] [[6 x [7 x i8]] [[7 x i8] c"\06\00\00\00\00\00\00", [7 x i8] zeroinitializer, [7 x i8] zeroinitializer, [7 x i8] zeroinitializer, [7 x i8] zeroinitializer, [7 x i8] zeroinitializer], [6 x [7 x i8]] zeroinitializer, [6 x [7 x i8]] zeroinitializer, [6 x [7 x i8]] zeroinitializer, [6 x [7 x i8]] zeroinitializer, [6 x [7 x i8]] zeroinitializer], align 1
|
||||
@p = internal global i64 0, align 8
|
||||
@y = local_unnamed_addr global i64* @p, align 4
|
||||
@b = internal unnamed_addr global i32 0, align 4
|
||||
@h = common local_unnamed_addr global i16 0, align 2
|
||||
@a = common local_unnamed_addr global i32 0, align 4
|
||||
@k = common local_unnamed_addr global i32 0, align 4
|
||||
@t11 = common local_unnamed_addr global i32 0, align 4
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define i32 @main() local_unnamed_addr {
|
||||
entry:
|
||||
%0 = load i32, i32* @t6, align 4
|
||||
%inc = add nsw i32 %0, 1
|
||||
store i32 %inc, i32* @t6, align 4
|
||||
store i16 4, i16* @h, align 2
|
||||
%1 = load i32, i32* @a, align 4
|
||||
%conv = trunc i32 %1 to i8
|
||||
store i32 1, i32* @f, align 4
|
||||
%2 = load i64, i64* @p, align 8
|
||||
%cmp4 = icmp slt i64 %2, 2
|
||||
%conv6 = zext i1 %cmp4 to i8
|
||||
%3 = load i16, i16* @h, align 2
|
||||
%conv7 = sext i16 %3 to i32
|
||||
%add = add nsw i32 %conv7, 1
|
||||
%f.promoted = load i32, i32* @f, align 4
|
||||
%4 = mul i32 %conv7, 7
|
||||
%5 = add i32 %4, 5
|
||||
%6 = sub i32 -1, %f.promoted
|
||||
%7 = icmp sgt i32 %6, -2
|
||||
%smax = select i1 %7, i32 %6, i32 -2
|
||||
%8 = sub i32 6, %smax
|
||||
%scevgep = getelementptr [6 x [6 x [7 x i8]]], [6 x [6 x [7 x i8]]]* @j, i32 0, i32 0, i32 %5, i32 %8
|
||||
%9 = add i32 %f.promoted, %smax
|
||||
%10 = add i32 %9, 2
|
||||
call void @llvm.memset.p0i8.i32(i8* %scevgep, i8 %conv6, i32 %10, i1 false)
|
||||
; CHECK: call void @llvm.memset.p0i8.i32(i8* getelementptr inbounds ([6 x [6 x [7 x i8]]], [6 x [6 x [7 x i8]]]* @j, i32 0, i{{32|64}} 5, i{{32|64}} 4, i32 1), i8 %conv6, i32 1, i1 false)
|
||||
; CHECK-NOT: call void @llvm.memset.p0i8.i32(i8* getelementptr ([6 x [6 x [7 x i8]]], [6 x [6 x [7 x i8]]]* @j, i64 1, i64 4, i64 4, i32 1)
|
||||
ret i32 0
|
||||
}
|
||||
; Function Attrs: argmemonly nounwind
|
||||
declare void @llvm.memset.p0i8.i32(i8* nocapture writeonly, i8, i32, i1)
|
||||
; RUN: opt -gvn -S -o - %s | FileCheck %s
|
||||
; RUN: opt -newgvn -S -o - %s | FileCheck %s
|
||||
; Test that the constantfolding getelementptr computation results in
|
||||
; j[5][4][1] (j+239)
|
||||
; and not [1][4][4][1] (#449) which is an incorrect out-of-range error
|
||||
target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
|
||||
target triple = "armv7-none-eabi"
|
||||
|
||||
@f = local_unnamed_addr global i32 2, align 4
|
||||
@t6 = local_unnamed_addr global i32 1, align 4
|
||||
@j = local_unnamed_addr global [6 x [6 x [7 x i8]]] [[6 x [7 x i8]] [[7 x i8] c"\06\00\00\00\00\00\00", [7 x i8] zeroinitializer, [7 x i8] zeroinitializer, [7 x i8] zeroinitializer, [7 x i8] zeroinitializer, [7 x i8] zeroinitializer], [6 x [7 x i8]] zeroinitializer, [6 x [7 x i8]] zeroinitializer, [6 x [7 x i8]] zeroinitializer, [6 x [7 x i8]] zeroinitializer, [6 x [7 x i8]] zeroinitializer], align 1
|
||||
@p = internal global i64 0, align 8
|
||||
@y = local_unnamed_addr global i64* @p, align 4
|
||||
@b = internal unnamed_addr global i32 0, align 4
|
||||
@h = common local_unnamed_addr global i16 0, align 2
|
||||
@a = common local_unnamed_addr global i32 0, align 4
|
||||
@k = common local_unnamed_addr global i32 0, align 4
|
||||
@t11 = common local_unnamed_addr global i32 0, align 4
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define i32 @main() local_unnamed_addr {
|
||||
entry:
|
||||
%0 = load i32, i32* @t6, align 4
|
||||
%inc = add nsw i32 %0, 1
|
||||
store i32 %inc, i32* @t6, align 4
|
||||
store i16 4, i16* @h, align 2
|
||||
%1 = load i32, i32* @a, align 4
|
||||
%conv = trunc i32 %1 to i8
|
||||
store i32 1, i32* @f, align 4
|
||||
%2 = load i64, i64* @p, align 8
|
||||
%cmp4 = icmp slt i64 %2, 2
|
||||
%conv6 = zext i1 %cmp4 to i8
|
||||
%3 = load i16, i16* @h, align 2
|
||||
%conv7 = sext i16 %3 to i32
|
||||
%add = add nsw i32 %conv7, 1
|
||||
%f.promoted = load i32, i32* @f, align 4
|
||||
%4 = mul i32 %conv7, 7
|
||||
%5 = add i32 %4, 5
|
||||
%6 = sub i32 -1, %f.promoted
|
||||
%7 = icmp sgt i32 %6, -2
|
||||
%smax = select i1 %7, i32 %6, i32 -2
|
||||
%8 = sub i32 6, %smax
|
||||
%scevgep = getelementptr [6 x [6 x [7 x i8]]], [6 x [6 x [7 x i8]]]* @j, i32 0, i32 0, i32 %5, i32 %8
|
||||
%9 = add i32 %f.promoted, %smax
|
||||
%10 = add i32 %9, 2
|
||||
call void @llvm.memset.p0i8.i32(i8* %scevgep, i8 %conv6, i32 %10, i1 false)
|
||||
; CHECK: call void @llvm.memset.p0i8.i32(i8* getelementptr inbounds ([6 x [6 x [7 x i8]]], [6 x [6 x [7 x i8]]]* @j, i32 0, i{{32|64}} 5, i{{32|64}} 4, i32 1), i8 %conv6, i32 1, i1 false)
|
||||
; CHECK-NOT: call void @llvm.memset.p0i8.i32(i8* getelementptr ([6 x [6 x [7 x i8]]], [6 x [6 x [7 x i8]]]* @j, i64 1, i64 4, i64 4, i32 1)
|
||||
ret i32 0
|
||||
}
|
||||
; Function Attrs: argmemonly nounwind
|
||||
declare void @llvm.memset.p0i8.i32(i8* nocapture writeonly, i8, i32, i1)
|
@ -1,5 +1,5 @@
|
||||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
||||
; RUN: opt < %s -constprop -S -o - | FileCheck %s
|
||||
; RUN: opt < %s -instsimplify -S -o - | FileCheck %s
|
||||
|
||||
; Testcase that verify that we don't get a faulty bitcast that cast between
|
||||
; different sizes.
|
@ -1,27 +1,27 @@
|
||||
; RUN: opt -instcombine -S -o - %s | FileCheck %s
|
||||
; Tests that we preserve the inrange attribute on indices where possible.
|
||||
|
||||
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
|
||||
target triple = "x86_64-unknown-linux-gnu"
|
||||
|
||||
%struct.A = type { i32 (...)** }
|
||||
|
||||
@vt = external global [3 x i8*]
|
||||
|
||||
; CHECK: define i32 (...)** @f0()
|
||||
define i32 (...)** @f0() {
|
||||
; CHECK-NEXT: ret i32 (...)** bitcast (i8** getelementptr inbounds ([3 x i8*], [3 x i8*]* @vt, inrange i64 0, i64 2) to i32 (...)**
|
||||
ret i32 (...)** getelementptr (i32 (...)*, i32 (...)** bitcast (i8** getelementptr inbounds ([3 x i8*], [3 x i8*]* @vt, inrange i64 0, i64 1) to i32 (...)**), i64 1)
|
||||
}
|
||||
|
||||
; CHECK: define i32 (...)** @f1()
|
||||
define i32 (...)** @f1() {
|
||||
; CHECK-NEXT: ret i32 (...)** getelementptr (i32 (...)*, i32 (...)** bitcast (i8** getelementptr inbounds ([3 x i8*], [3 x i8*]* @vt, i64 0, inrange i64 1) to i32 (...)**), i64 1)
|
||||
ret i32 (...)** getelementptr (i32 (...)*, i32 (...)** bitcast (i8** getelementptr inbounds ([3 x i8*], [3 x i8*]* @vt, i64 0, inrange i64 1) to i32 (...)**), i64 1)
|
||||
}
|
||||
|
||||
; CHECK: define i32 (...)** @f2()
|
||||
define i32 (...)** @f2() {
|
||||
; CHECK-NEXT: ret i32 (...)** getelementptr (i32 (...)*, i32 (...)** bitcast (i8** getelementptr inbounds ([3 x i8*], [3 x i8*]* @vt, i64 0, inrange i64 1) to i32 (...)**), i64 3)
|
||||
ret i32 (...)** getelementptr (i32 (...)*, i32 (...)** bitcast (i8** getelementptr inbounds ([3 x i8*], [3 x i8*]* @vt, i64 0, inrange i64 1) to i32 (...)**), i64 3)
|
||||
}
|
||||
; RUN: opt -instcombine -S -o - %s | FileCheck %s
|
||||
; Tests that we preserve the inrange attribute on indices where possible.
|
||||
|
||||
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
|
||||
target triple = "x86_64-unknown-linux-gnu"
|
||||
|
||||
%struct.A = type { i32 (...)** }
|
||||
|
||||
@vt = external global [3 x i8*]
|
||||
|
||||
; CHECK: define i32 (...)** @f0()
|
||||
define i32 (...)** @f0() {
|
||||
; CHECK-NEXT: ret i32 (...)** bitcast (i8** getelementptr inbounds ([3 x i8*], [3 x i8*]* @vt, inrange i64 0, i64 2) to i32 (...)**
|
||||
ret i32 (...)** getelementptr (i32 (...)*, i32 (...)** bitcast (i8** getelementptr inbounds ([3 x i8*], [3 x i8*]* @vt, inrange i64 0, i64 1) to i32 (...)**), i64 1)
|
||||
}
|
||||
|
||||
; CHECK: define i32 (...)** @f1()
|
||||
define i32 (...)** @f1() {
|
||||
; CHECK-NEXT: ret i32 (...)** getelementptr (i32 (...)*, i32 (...)** bitcast (i8** getelementptr inbounds ([3 x i8*], [3 x i8*]* @vt, i64 0, inrange i64 1) to i32 (...)**), i64 1)
|
||||
ret i32 (...)** getelementptr (i32 (...)*, i32 (...)** bitcast (i8** getelementptr inbounds ([3 x i8*], [3 x i8*]* @vt, i64 0, inrange i64 1) to i32 (...)**), i64 1)
|
||||
}
|
||||
|
||||
; CHECK: define i32 (...)** @f2()
|
||||
define i32 (...)** @f2() {
|
||||
; CHECK-NEXT: ret i32 (...)** getelementptr (i32 (...)*, i32 (...)** bitcast (i8** getelementptr inbounds ([3 x i8*], [3 x i8*]* @vt, i64 0, inrange i64 1) to i32 (...)**), i64 3)
|
||||
ret i32 (...)** getelementptr (i32 (...)*, i32 (...)** bitcast (i8** getelementptr inbounds ([3 x i8*], [3 x i8*]* @vt, i64 0, inrange i64 1) to i32 (...)**), i64 3)
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
; RUN: opt < %s -constprop -S | FileCheck %s
|
||||
; RUN: opt < %s -instsimplify -S | FileCheck %s
|
||||
|
||||
%struct = type { i32, [4 x i8] }
|
||||
|
@ -1,6 +1,6 @@
|
||||
; Ensure constant propagation of logical instructions is working correctly.
|
||||
|
||||
; RUN: opt < %s -constprop -die -S | FileCheck %s
|
||||
; RUN: opt < %s -instsimplify -die -S | FileCheck %s
|
||||
; CHECK-NOT: {{and|or|xor}}
|
||||
|
||||
define i32 @test1() {
|
@ -1,195 +1,195 @@
|
||||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
||||
; RUN: opt -early-cse -S -o - %s | FileCheck %s
|
||||
|
||||
declare double @acos(double)
|
||||
define double @f_acos() {
|
||||
; CHECK-LABEL: @f_acos(
|
||||
; CHECK-NEXT: ret double 0.000000e+00
|
||||
;
|
||||
%res = tail call fast double @acos(double 1.0)
|
||||
ret double %res
|
||||
}
|
||||
|
||||
declare float @asinf(float)
|
||||
define float @f_asinf() {
|
||||
; CHECK-LABEL: @f_asinf(
|
||||
; CHECK-NEXT: ret float 0x3FF921FB{{.+}}
|
||||
;
|
||||
%res = tail call fast float @asinf(float 1.0)
|
||||
ret float %res
|
||||
}
|
||||
|
||||
declare double @atan(double)
|
||||
define double @f_atan() {
|
||||
; CHECK-LABEL: @f_atan(
|
||||
; CHECK-NEXT: [[RES:%.*]] = tail call fast double @atan(double 1.000000e+00)
|
||||
; CHECK-NEXT: ret double 0x3FE921FB
|
||||
;
|
||||
%res = tail call fast double @atan(double 1.0)
|
||||
ret double %res
|
||||
}
|
||||
|
||||
declare float @cosf(float)
|
||||
define float @f_cosf() {
|
||||
; CHECK-LABEL: @f_cosf(
|
||||
; CHECK-NEXT: ret float 0x3FE14A2{{.+}}
|
||||
;
|
||||
%res = tail call fast float @cosf(float 1.0)
|
||||
ret float %res
|
||||
}
|
||||
|
||||
declare float @llvm.cos.f32(float)
|
||||
define float @i_cosf() {
|
||||
; CHECK-LABEL: @i_cosf(
|
||||
; CHECK-NEXT: ret float 0x3FE14A2
|
||||
;
|
||||
%res = tail call fast float @llvm.cos.f32(float 1.0)
|
||||
ret float %res
|
||||
}
|
||||
|
||||
declare double @cosh(double)
|
||||
define double @f_cosh() {
|
||||
; CHECK-LABEL: @f_cosh(
|
||||
; CHECK-NEXT: ret double 0x3FF8B075{{.+}}
|
||||
;
|
||||
%res = tail call fast double @cosh(double 1.0)
|
||||
ret double %res
|
||||
}
|
||||
|
||||
declare float @expf(float)
|
||||
define float @f_expf() {
|
||||
; CHECK-LABEL: @f_expf(
|
||||
; CHECK-NEXT: ret float 0x4005BF0A{{.+}}
|
||||
;
|
||||
%res = tail call fast float @expf(float 1.0)
|
||||
ret float %res
|
||||
}
|
||||
|
||||
declare float @llvm.exp.f32(float)
|
||||
define float @i_expf() {
|
||||
; CHECK-LABEL: @i_expf(
|
||||
; CHECK-NEXT: ret float 0x4005BF0A{{.+}}
|
||||
;
|
||||
%res = tail call fast float @llvm.exp.f32(float 1.0)
|
||||
ret float %res
|
||||
}
|
||||
|
||||
declare double @exp2(double)
|
||||
define double @f_exp2() {
|
||||
; CHECK-LABEL: @f_exp2(
|
||||
; CHECK-NEXT: ret double 2.000000e+00
|
||||
;
|
||||
%res = tail call fast double @exp2(double 1.0)
|
||||
ret double %res
|
||||
}
|
||||
|
||||
declare double @llvm.exp2.f64(double)
|
||||
define double @i_exp2() {
|
||||
; CHECK-LABEL: @i_exp2(
|
||||
; CHECK-NEXT: ret double 2.000000e+00
|
||||
;
|
||||
%res = tail call fast double @llvm.exp2.f64(double 1.0)
|
||||
ret double %res
|
||||
}
|
||||
|
||||
; FIXME: exp10() is not widely supported.
|
||||
declare float @exp10f(float)
|
||||
define float @f_exp10f() {
|
||||
; CHECK-LABEL: @f_exp10f(
|
||||
; CHECK-NEXT: [[RES:%.*]] = tail call float @exp10f(float 1.000000e+00)
|
||||
; CHECK-NEXT: ret float [[RES]]
|
||||
;
|
||||
%res = tail call float @exp10f(float 1.0)
|
||||
ret float %res
|
||||
}
|
||||
|
||||
declare double @log(double)
|
||||
define double @f_log() {
|
||||
; CHECK-LABEL: @f_log(
|
||||
; CHECK-NEXT: ret double 0.000000e+00
|
||||
;
|
||||
%res = tail call fast double @log(double 1.0)
|
||||
ret double %res
|
||||
}
|
||||
|
||||
declare double @llvm.log.f64(double)
|
||||
define double @i_log() {
|
||||
; CHECK-LABEL: @i_log(
|
||||
; CHECK-NEXT: ret double 0.000000e+00
|
||||
;
|
||||
%res = tail call fast double @llvm.log.f64(double 1.0)
|
||||
ret double %res
|
||||
}
|
||||
|
||||
declare float @log2f(float)
|
||||
define float @f_log2f() {
|
||||
; CHECK-LABEL: @f_log2f(
|
||||
; CHECK-NEXT: ret float 0.000000e+00
|
||||
;
|
||||
%res = tail call fast float @log2f(float 1.0)
|
||||
ret float %res
|
||||
}
|
||||
|
||||
declare float @llvm.log2.f32(float)
|
||||
define float @i_log2f() {
|
||||
; CHECK-LABEL: @i_log2f(
|
||||
; CHECK-NEXT: ret float 0.000000e+00
|
||||
;
|
||||
%res = tail call fast float @llvm.log2.f32(float 1.0)
|
||||
ret float %res
|
||||
}
|
||||
|
||||
declare double @log10(double)
|
||||
define double @f_log10() {
|
||||
; CHECK-LABEL: @f_log10(
|
||||
; CHECK-NEXT: ret double 0.000000e+00
|
||||
;
|
||||
%res = tail call fast double @log10(double 1.0)
|
||||
ret double %res
|
||||
}
|
||||
|
||||
declare float @sinf(float)
|
||||
define float @f_sinf() {
|
||||
; CHECK-LABEL: @f_sinf(
|
||||
; CHECK-NEXT: ret float 0x3FEAED54{{.+}}
|
||||
;
|
||||
%res = tail call fast float @sinf(float 1.0)
|
||||
ret float %res
|
||||
}
|
||||
|
||||
declare double @sinh(double)
|
||||
define double @f_sinh() {
|
||||
; CHECK-LABEL: @f_sinh(
|
||||
; CHECK-NEXT: ret double 0x3FF2CD9F{{.+}}
|
||||
;
|
||||
%res = tail call fast double @sinh(double 1.0)
|
||||
ret double %res
|
||||
}
|
||||
|
||||
declare float @sqrtf(float)
|
||||
define float @f_sqrtf() {
|
||||
; CHECK-LABEL: @f_sqrtf(
|
||||
; CHECK-NEXT: ret float 1.000000e+00
|
||||
;
|
||||
%res = tail call fast float @sqrtf(float 1.0)
|
||||
ret float %res
|
||||
}
|
||||
|
||||
declare double @tan(double)
|
||||
define double @f_tan() {
|
||||
; CHECK-LABEL: @f_tan(
|
||||
; CHECK-NEXT: ret double 0x3FF8EB24{{.+}}
|
||||
;
|
||||
%res = tail call fast double @tan(double 1.0)
|
||||
ret double %res
|
||||
}
|
||||
|
||||
declare float @tanhf(float)
|
||||
define float @f_tanhf() {
|
||||
; CHECK-LABEL: @f_tanhf(
|
||||
; CHECK-NEXT: [[RES:%.*]] = tail call fast float @tanhf(float 1.000000e+00)
|
||||
; CHECK-NEXT: ret float 0x3FE85EFA{{.+}}
|
||||
;
|
||||
%res = tail call fast float @tanhf(float 1.0)
|
||||
ret float %res
|
||||
}
|
||||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
||||
; RUN: opt -early-cse -S -o - %s | FileCheck %s
|
||||
|
||||
declare double @acos(double)
|
||||
define double @f_acos() {
|
||||
; CHECK-LABEL: @f_acos(
|
||||
; CHECK-NEXT: ret double 0.000000e+00
|
||||
;
|
||||
%res = tail call fast double @acos(double 1.0)
|
||||
ret double %res
|
||||
}
|
||||
|
||||
declare float @asinf(float)
|
||||
define float @f_asinf() {
|
||||
; CHECK-LABEL: @f_asinf(
|
||||
; CHECK-NEXT: ret float 0x3FF921FB{{.+}}
|
||||
;
|
||||
%res = tail call fast float @asinf(float 1.0)
|
||||
ret float %res
|
||||
}
|
||||
|
||||
declare double @atan(double)
|
||||
define double @f_atan() {
|
||||
; CHECK-LABEL: @f_atan(
|
||||
; CHECK-NEXT: [[RES:%.*]] = tail call fast double @atan(double 1.000000e+00)
|
||||
; CHECK-NEXT: ret double 0x3FE921FB
|
||||
;
|
||||
%res = tail call fast double @atan(double 1.0)
|
||||
ret double %res
|
||||
}
|
||||
|
||||
declare float @cosf(float)
|
||||
define float @f_cosf() {
|
||||
; CHECK-LABEL: @f_cosf(
|
||||
; CHECK-NEXT: ret float 0x3FE14A2{{.+}}
|
||||
;
|
||||
%res = tail call fast float @cosf(float 1.0)
|
||||
ret float %res
|
||||
}
|
||||
|
||||
declare float @llvm.cos.f32(float)
|
||||
define float @i_cosf() {
|
||||
; CHECK-LABEL: @i_cosf(
|
||||
; CHECK-NEXT: ret float 0x3FE14A2
|
||||
;
|
||||
%res = tail call fast float @llvm.cos.f32(float 1.0)
|
||||
ret float %res
|
||||
}
|
||||
|
||||
declare double @cosh(double)
|
||||
define double @f_cosh() {
|
||||
; CHECK-LABEL: @f_cosh(
|
||||
; CHECK-NEXT: ret double 0x3FF8B075{{.+}}
|
||||
;
|
||||
%res = tail call fast double @cosh(double 1.0)
|
||||
ret double %res
|
||||
}
|
||||
|
||||
declare float @expf(float)
|
||||
define float @f_expf() {
|
||||
; CHECK-LABEL: @f_expf(
|
||||
; CHECK-NEXT: ret float 0x4005BF0A{{.+}}
|
||||
;
|
||||
%res = tail call fast float @expf(float 1.0)
|
||||
ret float %res
|
||||
}
|
||||
|
||||
declare float @llvm.exp.f32(float)
|
||||
define float @i_expf() {
|
||||
; CHECK-LABEL: @i_expf(
|
||||
; CHECK-NEXT: ret float 0x4005BF0A{{.+}}
|
||||
;
|
||||
%res = tail call fast float @llvm.exp.f32(float 1.0)
|
||||
ret float %res
|
||||
}
|
||||
|
||||
declare double @exp2(double)
|
||||
define double @f_exp2() {
|
||||
; CHECK-LABEL: @f_exp2(
|
||||
; CHECK-NEXT: ret double 2.000000e+00
|
||||
;
|
||||
%res = tail call fast double @exp2(double 1.0)
|
||||
ret double %res
|
||||
}
|
||||
|
||||
declare double @llvm.exp2.f64(double)
|
||||
define double @i_exp2() {
|
||||
; CHECK-LABEL: @i_exp2(
|
||||
; CHECK-NEXT: ret double 2.000000e+00
|
||||
;
|
||||
%res = tail call fast double @llvm.exp2.f64(double 1.0)
|
||||
ret double %res
|
||||
}
|
||||
|
||||
; FIXME: exp10() is not widely supported.
|
||||
declare float @exp10f(float)
|
||||
define float @f_exp10f() {
|
||||
; CHECK-LABEL: @f_exp10f(
|
||||
; CHECK-NEXT: [[RES:%.*]] = tail call float @exp10f(float 1.000000e+00)
|
||||
; CHECK-NEXT: ret float [[RES]]
|
||||
;
|
||||
%res = tail call float @exp10f(float 1.0)
|
||||
ret float %res
|
||||
}
|
||||
|
||||
declare double @log(double)
|
||||
define double @f_log() {
|
||||
; CHECK-LABEL: @f_log(
|
||||
; CHECK-NEXT: ret double 0.000000e+00
|
||||
;
|
||||
%res = tail call fast double @log(double 1.0)
|
||||
ret double %res
|
||||
}
|
||||
|
||||
declare double @llvm.log.f64(double)
|
||||
define double @i_log() {
|
||||
; CHECK-LABEL: @i_log(
|
||||
; CHECK-NEXT: ret double 0.000000e+00
|
||||
;
|
||||
%res = tail call fast double @llvm.log.f64(double 1.0)
|
||||
ret double %res
|
||||
}
|
||||
|
||||
declare float @log2f(float)
|
||||
define float @f_log2f() {
|
||||
; CHECK-LABEL: @f_log2f(
|
||||
; CHECK-NEXT: ret float 0.000000e+00
|
||||
;
|
||||
%res = tail call fast float @log2f(float 1.0)
|
||||
ret float %res
|
||||
}
|
||||
|
||||
declare float @llvm.log2.f32(float)
|
||||
define float @i_log2f() {
|
||||
; CHECK-LABEL: @i_log2f(
|
||||
; CHECK-NEXT: ret float 0.000000e+00
|
||||
;
|
||||
%res = tail call fast float @llvm.log2.f32(float 1.0)
|
||||
ret float %res
|
||||
}
|
||||
|
||||
declare double @log10(double)
|
||||
define double @f_log10() {
|
||||
; CHECK-LABEL: @f_log10(
|
||||
; CHECK-NEXT: ret double 0.000000e+00
|
||||
;
|
||||
%res = tail call fast double @log10(double 1.0)
|
||||
ret double %res
|
||||
}
|
||||
|
||||
declare float @sinf(float)
|
||||
define float @f_sinf() {
|
||||
; CHECK-LABEL: @f_sinf(
|
||||
; CHECK-NEXT: ret float 0x3FEAED54{{.+}}
|
||||
;
|
||||
%res = tail call fast float @sinf(float 1.0)
|
||||
ret float %res
|
||||
}
|
||||
|
||||
declare double @sinh(double)
|
||||
define double @f_sinh() {
|
||||
; CHECK-LABEL: @f_sinh(
|
||||
; CHECK-NEXT: ret double 0x3FF2CD9F{{.+}}
|
||||
;
|
||||
%res = tail call fast double @sinh(double 1.0)
|
||||
ret double %res
|
||||
}
|
||||
|
||||
declare float @sqrtf(float)
|
||||
define float @f_sqrtf() {
|
||||
; CHECK-LABEL: @f_sqrtf(
|
||||
; CHECK-NEXT: ret float 1.000000e+00
|
||||
;
|
||||
%res = tail call fast float @sqrtf(float 1.0)
|
||||
ret float %res
|
||||
}
|
||||
|
||||
declare double @tan(double)
|
||||
define double @f_tan() {
|
||||
; CHECK-LABEL: @f_tan(
|
||||
; CHECK-NEXT: ret double 0x3FF8EB24{{.+}}
|
||||
;
|
||||
%res = tail call fast double @tan(double 1.0)
|
||||
ret double %res
|
||||
}
|
||||
|
||||
declare float @tanhf(float)
|
||||
define float @f_tanhf() {
|
||||
; CHECK-LABEL: @f_tanhf(
|
||||
; CHECK-NEXT: [[RES:%.*]] = tail call fast float @tanhf(float 1.000000e+00)
|
||||
; CHECK-NEXT: ret float 0x3FE85EFA{{.+}}
|
||||
;
|
||||
%res = tail call fast float @tanhf(float 1.0)
|
||||
ret float %res
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
||||
; RUN: opt -constprop -S < %s | FileCheck %s
|
||||
; RUN: opt -instsimplify -S < %s | FileCheck %s
|
||||
|
||||
declare float @llvm.minnum.f32(float, float)
|
||||
declare <4 x float> @llvm.minnum.v4f32(<4 x float>, <4 x float>)
|
@ -1,5 +1,5 @@
|
||||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
||||
; RUN: opt < %s -constprop -S | FileCheck %s --check-prefixes=CHECK,CONSTPROP
|
||||
; RUN: opt < %s -instsimplify -S | FileCheck %s --check-prefixes=CHECK,CONSTPROP
|
||||
; RUN: opt < %s -instsimplify -S | FileCheck %s --check-prefixes=CHECK,INSTSIMPLIFY
|
||||
; We must *NOT* have any check-lines with prefixes other than CHECK here.
|
||||
; If we do, that means the rules are different between the passes.
|
@ -1,7 +1,7 @@
|
||||
; This is a basic sanity check for constant propagation. The add instruction
|
||||
; should be eliminated.
|
||||
|
||||
; RUN: opt < %s -constprop -die -S | not grep phi
|
||||
; RUN: opt < %s -instsimplify -die -S | not grep phi
|
||||
|
||||
define i32 @test(i1 %B) {
|
||||
BB0:
|
@ -1,6 +1,6 @@
|
||||
; Ensure constant propagation of remainder instructions is working correctly.
|
||||
|
||||
; RUN: opt < %s -constprop -die -S | not grep rem
|
||||
; RUN: opt < %s -instsimplify -die -S | not grep rem
|
||||
|
||||
define i32 @test1() {
|
||||
%R = srem i32 4, 3 ; <i32> [#uses=1]
|
@ -1,109 +1,109 @@
|
||||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
||||
; RUN: opt -S -early-cse < %s | FileCheck %s
|
||||
|
||||
declare float @nearbyintf(float) #0
|
||||
declare float @llvm.nearbyint.f32(float) #0
|
||||
declare double @nearbyint(double) #0
|
||||
declare double @llvm.nearbyint.f64(double) #0
|
||||
declare float @rintf(float) #0
|
||||
declare float @llvm.rint.f32(float) #0
|
||||
declare double @rint(double) #0
|
||||
declare double @llvm.rint.f64(double) #0
|
||||
|
||||
define float @constant_fold_rint_f32_01() #0 {
|
||||
; CHECK-LABEL: @constant_fold_rint_f32_01(
|
||||
; CHECK-NEXT: ret float 1.000000e+00
|
||||
;
|
||||
%x = call float @nearbyintf(float 1.25) #0
|
||||
ret float %x
|
||||
}
|
||||
|
||||
define float @constant_fold_rint_f32_02() #0 {
|
||||
; CHECK-LABEL: @constant_fold_rint_f32_02(
|
||||
; CHECK-NEXT: ret float -1.000000e+00
|
||||
;
|
||||
%x = call float @llvm.nearbyint.f32(float -1.25) #0
|
||||
ret float %x
|
||||
}
|
||||
|
||||
define float @constant_fold_rint_f32_03() #0 {
|
||||
; CHECK-LABEL: @constant_fold_rint_f32_03(
|
||||
; CHECK-NEXT: ret float 2.000000e+00
|
||||
;
|
||||
%x = call float @rintf(float 1.5) #0
|
||||
ret float %x
|
||||
}
|
||||
|
||||
define float @constant_fold_rint_f32_04() #0 {
|
||||
; CHECK-LABEL: @constant_fold_rint_f32_04(
|
||||
; CHECK-NEXT: ret float -2.000000e+00
|
||||
;
|
||||
%x = call float @llvm.rint.f32(float -1.5) #0
|
||||
ret float %x
|
||||
}
|
||||
|
||||
define float @constant_fold_rint_f32_05() #0 {
|
||||
; CHECK-LABEL: @constant_fold_rint_f32_05(
|
||||
; CHECK-NEXT: ret float 3.000000e+00
|
||||
;
|
||||
%x = call float @nearbyintf(float 2.75) #0
|
||||
ret float %x
|
||||
}
|
||||
|
||||
define float @constant_fold_rint_f32_06() #0 {
|
||||
; CHECK-LABEL: @constant_fold_rint_f32_06(
|
||||
; CHECK-NEXT: ret float -3.000000e+00
|
||||
;
|
||||
%x = call float @llvm.nearbyint.f32(float -2.75) #0
|
||||
ret float %x
|
||||
}
|
||||
|
||||
define double @constant_fold_rint_f64_01() #0 {
|
||||
; CHECK-LABEL: @constant_fold_rint_f64_01(
|
||||
; CHECK-NEXT: ret double 1.000000e+00
|
||||
;
|
||||
%x = call double @rint(double 1.3) #0
|
||||
ret double %x
|
||||
}
|
||||
|
||||
define double @constant_fold_rint_f64_02() #0 {
|
||||
; CHECK-LABEL: @constant_fold_rint_f64_02(
|
||||
; CHECK-NEXT: ret double -1.000000e+00
|
||||
;
|
||||
%x = call double @llvm.rint.f64(double -1.3) #0
|
||||
ret double %x
|
||||
}
|
||||
|
||||
define double @constant_fold_rint_f64_03() #0 {
|
||||
; CHECK-LABEL: @constant_fold_rint_f64_03(
|
||||
; CHECK-NEXT: ret double 2.000000e+00
|
||||
;
|
||||
%x = call double @nearbyint(double 1.5) #0
|
||||
ret double %x
|
||||
}
|
||||
|
||||
define double @constant_fold_rint_f64_04() #0 {
|
||||
; CHECK-LABEL: @constant_fold_rint_f64_04(
|
||||
; CHECK-NEXT: ret double -2.000000e+00
|
||||
;
|
||||
%x = call double @llvm.nearbyint.f64(double -1.5) #0
|
||||
ret double %x
|
||||
}
|
||||
|
||||
define double @constant_fold_rint_f64_05() #0 {
|
||||
; CHECK-LABEL: @constant_fold_rint_f64_05(
|
||||
; CHECK-NEXT: ret double 3.000000e+00
|
||||
;
|
||||
%x = call double @rint(double 2.7) #0
|
||||
ret double %x
|
||||
}
|
||||
|
||||
define double @constant_fold_rint_f64_06() #0 {
|
||||
; CHECK-LABEL: @constant_fold_rint_f64_06(
|
||||
; CHECK-NEXT: ret double -3.000000e+00
|
||||
;
|
||||
%x = call double @llvm.rint.f64(double -2.7) #0
|
||||
ret double %x
|
||||
}
|
||||
|
||||
attributes #0 = { nounwind readnone }
|
||||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
||||
; RUN: opt -S -early-cse < %s | FileCheck %s
|
||||
|
||||
declare float @nearbyintf(float) #0
|
||||
declare float @llvm.nearbyint.f32(float) #0
|
||||
declare double @nearbyint(double) #0
|
||||
declare double @llvm.nearbyint.f64(double) #0
|
||||
declare float @rintf(float) #0
|
||||
declare float @llvm.rint.f32(float) #0
|
||||
declare double @rint(double) #0
|
||||
declare double @llvm.rint.f64(double) #0
|
||||
|
||||
define float @constant_fold_rint_f32_01() #0 {
|
||||
; CHECK-LABEL: @constant_fold_rint_f32_01(
|
||||
; CHECK-NEXT: ret float 1.000000e+00
|
||||
;
|
||||
%x = call float @nearbyintf(float 1.25) #0
|
||||
ret float %x
|
||||
}
|
||||
|
||||
define float @constant_fold_rint_f32_02() #0 {
|
||||
; CHECK-LABEL: @constant_fold_rint_f32_02(
|
||||
; CHECK-NEXT: ret float -1.000000e+00
|
||||
;
|
||||
%x = call float @llvm.nearbyint.f32(float -1.25) #0
|
||||
ret float %x
|
||||
}
|
||||
|
||||
define float @constant_fold_rint_f32_03() #0 {
|
||||
; CHECK-LABEL: @constant_fold_rint_f32_03(
|
||||
; CHECK-NEXT: ret float 2.000000e+00
|
||||
;
|
||||
%x = call float @rintf(float 1.5) #0
|
||||
ret float %x
|
||||
}
|
||||
|
||||
define float @constant_fold_rint_f32_04() #0 {
|
||||
; CHECK-LABEL: @constant_fold_rint_f32_04(
|
||||
; CHECK-NEXT: ret float -2.000000e+00
|
||||
;
|
||||
%x = call float @llvm.rint.f32(float -1.5) #0
|
||||
ret float %x
|
||||
}
|
||||
|
||||
define float @constant_fold_rint_f32_05() #0 {
|
||||
; CHECK-LABEL: @constant_fold_rint_f32_05(
|
||||
; CHECK-NEXT: ret float 3.000000e+00
|
||||
;
|
||||
%x = call float @nearbyintf(float 2.75) #0
|
||||
ret float %x
|
||||
}
|
||||
|
||||
define float @constant_fold_rint_f32_06() #0 {
|
||||
; CHECK-LABEL: @constant_fold_rint_f32_06(
|
||||
; CHECK-NEXT: ret float -3.000000e+00
|
||||
;
|
||||
%x = call float @llvm.nearbyint.f32(float -2.75) #0
|
||||
ret float %x
|
||||
}
|
||||
|
||||
define double @constant_fold_rint_f64_01() #0 {
|
||||
; CHECK-LABEL: @constant_fold_rint_f64_01(
|
||||
; CHECK-NEXT: ret double 1.000000e+00
|
||||
;
|
||||
%x = call double @rint(double 1.3) #0
|
||||
ret double %x
|
||||
}
|
||||
|
||||
define double @constant_fold_rint_f64_02() #0 {
|
||||
; CHECK-LABEL: @constant_fold_rint_f64_02(
|
||||
; CHECK-NEXT: ret double -1.000000e+00
|
||||
;
|
||||
%x = call double @llvm.rint.f64(double -1.3) #0
|
||||
ret double %x
|
||||
}
|
||||
|
||||
define double @constant_fold_rint_f64_03() #0 {
|
||||
; CHECK-LABEL: @constant_fold_rint_f64_03(
|
||||
; CHECK-NEXT: ret double 2.000000e+00
|
||||
;
|
||||
%x = call double @nearbyint(double 1.5) #0
|
||||
ret double %x
|
||||
}
|
||||
|
||||
define double @constant_fold_rint_f64_04() #0 {
|
||||
; CHECK-LABEL: @constant_fold_rint_f64_04(
|
||||
; CHECK-NEXT: ret double -2.000000e+00
|
||||
;
|
||||
%x = call double @llvm.nearbyint.f64(double -1.5) #0
|
||||
ret double %x
|
||||
}
|
||||
|
||||
define double @constant_fold_rint_f64_05() #0 {
|
||||
; CHECK-LABEL: @constant_fold_rint_f64_05(
|
||||
; CHECK-NEXT: ret double 3.000000e+00
|
||||
;
|
||||
%x = call double @rint(double 2.7) #0
|
||||
ret double %x
|
||||
}
|
||||
|
||||
define double @constant_fold_rint_f64_06() #0 {
|
||||
; CHECK-LABEL: @constant_fold_rint_f64_06(
|
||||
; CHECK-NEXT: ret double -3.000000e+00
|
||||
;
|
||||
%x = call double @llvm.rint.f64(double -2.7) #0
|
||||
ret double %x
|
||||
}
|
||||
|
||||
attributes #0 = { nounwind readnone }
|
@ -1,92 +1,92 @@
|
||||
; RUN: opt -S -early-cse < %s | FileCheck %s
|
||||
|
||||
declare float @roundf(float) #0
|
||||
declare float @llvm.round.f32(float) #0
|
||||
declare double @round(double) #0
|
||||
declare double @llvm.round.f64(double) #0
|
||||
|
||||
; CHECK-LABEL: @constant_fold_round_f32_01
|
||||
; CHECK-NEXT: ret float 1.000000e+00
|
||||
define float @constant_fold_round_f32_01() #0 {
|
||||
%x = call float @roundf(float 1.25) #0
|
||||
ret float %x
|
||||
}
|
||||
|
||||
; CHECK-LABEL: @constant_fold_round_f32_02
|
||||
; CHECK-NEXT: ret float -1.000000e+00
|
||||
define float @constant_fold_round_f32_02() #0 {
|
||||
%x = call float @llvm.round.f32(float -1.25) #0
|
||||
ret float %x
|
||||
}
|
||||
|
||||
; CHECK-LABEL: @constant_fold_round_f32_03
|
||||
; CHECK-NEXT: ret float 2.000000e+00
|
||||
define float @constant_fold_round_f32_03() #0 {
|
||||
%x = call float @roundf(float 1.5) #0
|
||||
ret float %x
|
||||
}
|
||||
|
||||
; CHECK-LABEL: @constant_fold_round_f32_04
|
||||
; CHECK-NEXT: ret float -2.000000e+00
|
||||
define float @constant_fold_round_f32_04() #0 {
|
||||
%x = call float @llvm.round.f32(float -1.5) #0
|
||||
ret float %x
|
||||
}
|
||||
|
||||
; CHECK-LABEL: @constant_fold_round_f32_05
|
||||
; CHECK-NEXT: ret float 3.000000e+00
|
||||
define float @constant_fold_round_f32_05() #0 {
|
||||
%x = call float @roundf(float 2.75) #0
|
||||
ret float %x
|
||||
}
|
||||
|
||||
; CHECK-LABEL: @constant_fold_round_f32_06
|
||||
; CHECK-NEXT: ret float -3.000000e+00
|
||||
define float @constant_fold_round_f32_06() #0 {
|
||||
%x = call float @llvm.round.f32(float -2.75) #0
|
||||
ret float %x
|
||||
}
|
||||
|
||||
; CHECK-LABEL: @constant_fold_round_f64_01
|
||||
; CHECK-NEXT: ret double 1.000000e+00
|
||||
define double @constant_fold_round_f64_01() #0 {
|
||||
%x = call double @round(double 1.3) #0
|
||||
ret double %x
|
||||
}
|
||||
|
||||
; CHECK-LABEL: @constant_fold_round_f64_02
|
||||
; CHECK-NEXT: ret double -1.000000e+00
|
||||
define double @constant_fold_round_f64_02() #0 {
|
||||
%x = call double @llvm.round.f64(double -1.3) #0
|
||||
ret double %x
|
||||
}
|
||||
|
||||
; CHECK-LABEL: @constant_fold_round_f64_03
|
||||
; CHECK-NEXT: ret double 2.000000e+00
|
||||
define double @constant_fold_round_f64_03() #0 {
|
||||
%x = call double @round(double 1.5) #0
|
||||
ret double %x
|
||||
}
|
||||
|
||||
; CHECK-LABEL: @constant_fold_round_f64_04
|
||||
; CHECK-NEXT: ret double -2.000000e+00
|
||||
define double @constant_fold_round_f64_04() #0 {
|
||||
%x = call double @llvm.round.f64(double -1.5) #0
|
||||
ret double %x
|
||||
}
|
||||
|
||||
; CHECK-LABEL: @constant_fold_round_f64_05
|
||||
; CHECK-NEXT: ret double 3.000000e+00
|
||||
define double @constant_fold_round_f64_05() #0 {
|
||||
%x = call double @round(double 2.7) #0
|
||||
ret double %x
|
||||
}
|
||||
|
||||
; CHECK-LABEL: @constant_fold_round_f64_06
|
||||
; CHECK-NEXT: ret double -3.000000e+00
|
||||
define double @constant_fold_round_f64_06() #0 {
|
||||
%x = call double @llvm.round.f64(double -2.7) #0
|
||||
ret double %x
|
||||
}
|
||||
|
||||
attributes #0 = { nounwind readnone }
|
||||
; RUN: opt -S -early-cse < %s | FileCheck %s
|
||||
|
||||
declare float @roundf(float) #0
|
||||
declare float @llvm.round.f32(float) #0
|
||||
declare double @round(double) #0
|
||||
declare double @llvm.round.f64(double) #0
|
||||
|
||||
; CHECK-LABEL: @constant_fold_round_f32_01
|
||||
; CHECK-NEXT: ret float 1.000000e+00
|
||||
define float @constant_fold_round_f32_01() #0 {
|
||||
%x = call float @roundf(float 1.25) #0
|
||||
ret float %x
|
||||
}
|
||||
|
||||
; CHECK-LABEL: @constant_fold_round_f32_02
|
||||
; CHECK-NEXT: ret float -1.000000e+00
|
||||
define float @constant_fold_round_f32_02() #0 {
|
||||
%x = call float @llvm.round.f32(float -1.25) #0
|
||||
ret float %x
|
||||
}
|
||||
|
||||
; CHECK-LABEL: @constant_fold_round_f32_03
|
||||
; CHECK-NEXT: ret float 2.000000e+00
|
||||
define float @constant_fold_round_f32_03() #0 {
|
||||
%x = call float @roundf(float 1.5) #0
|
||||
ret float %x
|
||||
}
|
||||
|
||||
; CHECK-LABEL: @constant_fold_round_f32_04
|
||||
; CHECK-NEXT: ret float -2.000000e+00
|
||||
define float @constant_fold_round_f32_04() #0 {
|
||||
%x = call float @llvm.round.f32(float -1.5) #0
|
||||
ret float %x
|
||||
}
|
||||
|
||||
; CHECK-LABEL: @constant_fold_round_f32_05
|
||||
; CHECK-NEXT: ret float 3.000000e+00
|
||||
define float @constant_fold_round_f32_05() #0 {
|
||||
%x = call float @roundf(float 2.75) #0
|
||||
ret float %x
|
||||
}
|
||||
|
||||
; CHECK-LABEL: @constant_fold_round_f32_06
|
||||
; CHECK-NEXT: ret float -3.000000e+00
|
||||
define float @constant_fold_round_f32_06() #0 {
|
||||
%x = call float @llvm.round.f32(float -2.75) #0
|
||||
ret float %x
|
||||
}
|
||||
|
||||
; CHECK-LABEL: @constant_fold_round_f64_01
|
||||
; CHECK-NEXT: ret double 1.000000e+00
|
||||
define double @constant_fold_round_f64_01() #0 {
|
||||
%x = call double @round(double 1.3) #0
|
||||
ret double %x
|
||||
}
|
||||
|
||||
; CHECK-LABEL: @constant_fold_round_f64_02
|
||||
; CHECK-NEXT: ret double -1.000000e+00
|
||||
define double @constant_fold_round_f64_02() #0 {
|
||||
%x = call double @llvm.round.f64(double -1.3) #0
|
||||
ret double %x
|
||||
}
|
||||
|
||||
; CHECK-LABEL: @constant_fold_round_f64_03
|
||||
; CHECK-NEXT: ret double 2.000000e+00
|
||||
define double @constant_fold_round_f64_03() #0 {
|
||||
%x = call double @round(double 1.5) #0
|
||||
ret double %x
|
||||
}
|
||||
|
||||
; CHECK-LABEL: @constant_fold_round_f64_04
|
||||
; CHECK-NEXT: ret double -2.000000e+00
|
||||
define double @constant_fold_round_f64_04() #0 {
|
||||
%x = call double @llvm.round.f64(double -1.5) #0
|
||||
ret double %x
|
||||
}
|
||||
|
||||
; CHECK-LABEL: @constant_fold_round_f64_05
|
||||
; CHECK-NEXT: ret double 3.000000e+00
|
||||
define double @constant_fold_round_f64_05() #0 {
|
||||
%x = call double @round(double 2.7) #0
|
||||
ret double %x
|
||||
}
|
||||
|
||||
; CHECK-LABEL: @constant_fold_round_f64_06
|
||||
; CHECK-NEXT: ret double -3.000000e+00
|
||||
define double @constant_fold_round_f64_06() #0 {
|
||||
%x = call double @llvm.round.f64(double -2.7) #0
|
||||
ret double %x
|
||||
}
|
||||
|
||||
attributes #0 = { nounwind readnone }
|
@ -1,5 +1,5 @@
|
||||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
||||
; RUN: opt < %s -constprop -S | FileCheck %s
|
||||
; RUN: opt < %s -instsimplify -S | FileCheck %s
|
||||
|
||||
declare i8 @llvm.uadd.sat.i8(i8, i8)
|
||||
declare i8 @llvm.sadd.sat.i8(i8, i8)
|
@ -1,4 +1,4 @@
|
||||
; RUN: opt < %s -constprop -S | FileCheck %s
|
||||
; RUN: opt < %s -instsimplify -S | FileCheck %s
|
||||
|
||||
; CHECK-LABEL: shift_undef_64
|
||||
define void @shift_undef_64(i64* %p) {
|
@ -1,5 +1,5 @@
|
||||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
||||
; RUN: opt < %s -constprop -S | FileCheck %s
|
||||
; RUN: opt < %s -instsimplify -S | FileCheck %s
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
; Simple test using scalar layout.
|
@ -1,5 +1,5 @@
|
||||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
||||
; RUN: opt < %s -constprop -S | FileCheck %s
|
||||
; RUN: opt < %s -instsimplify -S | FileCheck %s
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
; Simple test using scalar layout.
|
@ -1,4 +1,4 @@
|
||||
; RUN: opt < %s -constprop -S | FileCheck %s
|
||||
; RUN: opt < %s -instsimplify -S | FileCheck %s
|
||||
; REQUIRES: x86-registered-target
|
||||
|
||||
define i1 @test_sse_cvts_exact() nounwind readnone {
|
@ -1,73 +1,73 @@
|
||||
; NOTE: This is a timeout test for some O(something silly) constant folding behaviour. It may not be the best test. Providing it finishes, it passes.
|
||||
; RUN: opt < %s -O3 -S | FileCheck %s
|
||||
target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
|
||||
target triple = "armv8-none-eabi"
|
||||
|
||||
%struct.ST = type { %struct.ST* }
|
||||
|
||||
@global = internal global [121 x i8] zeroinitializer, align 1
|
||||
|
||||
define void @func() #0 {
|
||||
;CHECK-LABEL: func
|
||||
entry:
|
||||
%s = alloca %struct.ST*, align 4
|
||||
%j = alloca i32, align 4
|
||||
store %struct.ST* bitcast ([121 x i8]* @global to %struct.ST*), %struct.ST** %s, align 4
|
||||
store i32 0, i32* %j, align 4
|
||||
br label %for.cond
|
||||
|
||||
for.cond: ; preds = %for.inc, %entry
|
||||
%0 = load i32, i32* %j, align 4
|
||||
%cmp = icmp slt i32 %0, 30
|
||||
br i1 %cmp, label %for.body, label %for.end
|
||||
|
||||
for.body: ; preds = %for.cond
|
||||
%1 = load %struct.ST*, %struct.ST** %s, align 4
|
||||
%2 = bitcast %struct.ST* %1 to i8*
|
||||
%add.ptr = getelementptr inbounds i8, i8* %2, i32 4
|
||||
%3 = ptrtoint i8* %add.ptr to i32
|
||||
%4 = load %struct.ST*, %struct.ST** %s, align 4
|
||||
%5 = bitcast %struct.ST* %4 to i8*
|
||||
%add.ptr1 = getelementptr inbounds i8, i8* %5, i32 4
|
||||
%6 = ptrtoint i8* %add.ptr1 to i32
|
||||
%rem = urem i32 %6, 2
|
||||
%cmp2 = icmp eq i32 %rem, 0
|
||||
br i1 %cmp2, label %cond.true, label %cond.false
|
||||
|
||||
cond.true: ; preds = %for.body
|
||||
br label %cond.end
|
||||
|
||||
cond.false: ; preds = %for.body
|
||||
%7 = load %struct.ST*, %struct.ST** %s, align 4
|
||||
%8 = bitcast %struct.ST* %7 to i8*
|
||||
%add.ptr3 = getelementptr inbounds i8, i8* %8, i32 4
|
||||
%9 = ptrtoint i8* %add.ptr3 to i32
|
||||
%rem4 = urem i32 %9, 2
|
||||
br label %cond.end
|
||||
|
||||
cond.end: ; preds = %cond.false, %cond.true
|
||||
%cond = phi i32 [ 0, %cond.true ], [ %rem4, %cond.false ]
|
||||
%add = add i32 %3, %cond
|
||||
%10 = inttoptr i32 %add to %struct.ST*
|
||||
%11 = load %struct.ST*, %struct.ST** %s, align 4
|
||||
%next = getelementptr inbounds %struct.ST, %struct.ST* %11, i32 0, i32 0
|
||||
store %struct.ST* %10, %struct.ST** %next, align 4
|
||||
%12 = load %struct.ST*, %struct.ST** %s, align 4
|
||||
%next5 = getelementptr inbounds %struct.ST, %struct.ST* %12, i32 0, i32 0
|
||||
%13 = load %struct.ST*, %struct.ST** %next5, align 4
|
||||
store %struct.ST* %13, %struct.ST** %s, align 4
|
||||
br label %for.inc
|
||||
|
||||
for.inc: ; preds = %cond.end
|
||||
%14 = load i32, i32* %j, align 4
|
||||
%inc = add nsw i32 %14, 1
|
||||
store i32 %inc, i32* %j, align 4
|
||||
br label %for.cond
|
||||
|
||||
for.end: ; preds = %for.cond
|
||||
%15 = load %struct.ST*, %struct.ST** %s, align 4
|
||||
%next6 = getelementptr inbounds %struct.ST, %struct.ST* %15, i32 0, i32 0
|
||||
store %struct.ST* null, %struct.ST** %next6, align 4
|
||||
ret void
|
||||
}
|
||||
|
||||
; NOTE: This is a timeout test for some O(something silly) constant folding behaviour. It may not be the best test. Providing it finishes, it passes.
|
||||
; RUN: opt < %s -O3 -S | FileCheck %s
|
||||
target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
|
||||
target triple = "armv8-none-eabi"
|
||||
|
||||
%struct.ST = type { %struct.ST* }
|
||||
|
||||
@global = internal global [121 x i8] zeroinitializer, align 1
|
||||
|
||||
define void @func() #0 {
|
||||
;CHECK-LABEL: func
|
||||
entry:
|
||||
%s = alloca %struct.ST*, align 4
|
||||
%j = alloca i32, align 4
|
||||
store %struct.ST* bitcast ([121 x i8]* @global to %struct.ST*), %struct.ST** %s, align 4
|
||||
store i32 0, i32* %j, align 4
|
||||
br label %for.cond
|
||||
|
||||
for.cond: ; preds = %for.inc, %entry
|
||||
%0 = load i32, i32* %j, align 4
|
||||
%cmp = icmp slt i32 %0, 30
|
||||
br i1 %cmp, label %for.body, label %for.end
|
||||
|
||||
for.body: ; preds = %for.cond
|
||||
%1 = load %struct.ST*, %struct.ST** %s, align 4
|
||||
%2 = bitcast %struct.ST* %1 to i8*
|
||||
%add.ptr = getelementptr inbounds i8, i8* %2, i32 4
|
||||
%3 = ptrtoint i8* %add.ptr to i32
|
||||
%4 = load %struct.ST*, %struct.ST** %s, align 4
|
||||
%5 = bitcast %struct.ST* %4 to i8*
|
||||
%add.ptr1 = getelementptr inbounds i8, i8* %5, i32 4
|
||||
%6 = ptrtoint i8* %add.ptr1 to i32
|
||||
%rem = urem i32 %6, 2
|
||||
%cmp2 = icmp eq i32 %rem, 0
|
||||
br i1 %cmp2, label %cond.true, label %cond.false
|
||||
|
||||
cond.true: ; preds = %for.body
|
||||
br label %cond.end
|
||||
|
||||
cond.false: ; preds = %for.body
|
||||
%7 = load %struct.ST*, %struct.ST** %s, align 4
|
||||
%8 = bitcast %struct.ST* %7 to i8*
|
||||
%add.ptr3 = getelementptr inbounds i8, i8* %8, i32 4
|
||||
%9 = ptrtoint i8* %add.ptr3 to i32
|
||||
%rem4 = urem i32 %9, 2
|
||||
br label %cond.end
|
||||
|
||||
cond.end: ; preds = %cond.false, %cond.true
|
||||
%cond = phi i32 [ 0, %cond.true ], [ %rem4, %cond.false ]
|
||||
%add = add i32 %3, %cond
|
||||
%10 = inttoptr i32 %add to %struct.ST*
|
||||
%11 = load %struct.ST*, %struct.ST** %s, align 4
|
||||
%next = getelementptr inbounds %struct.ST, %struct.ST* %11, i32 0, i32 0
|
||||
store %struct.ST* %10, %struct.ST** %next, align 4
|
||||
%12 = load %struct.ST*, %struct.ST** %s, align 4
|
||||
%next5 = getelementptr inbounds %struct.ST, %struct.ST* %12, i32 0, i32 0
|
||||
%13 = load %struct.ST*, %struct.ST** %next5, align 4
|
||||
store %struct.ST* %13, %struct.ST** %s, align 4
|
||||
br label %for.inc
|
||||
|
||||
for.inc: ; preds = %cond.end
|
||||
%14 = load i32, i32* %j, align 4
|
||||
%inc = add nsw i32 %14, 1
|
||||
store i32 %inc, i32* %j, align 4
|
||||
br label %for.cond
|
||||
|
||||
for.end: ; preds = %for.cond
|
||||
%15 = load %struct.ST*, %struct.ST** %s, align 4
|
||||
%next6 = getelementptr inbounds %struct.ST, %struct.ST* %15, i32 0, i32 0
|
||||
store %struct.ST* null, %struct.ST** %next6, align 4
|
||||
ret void
|
||||
}
|
||||
|
@ -1,105 +1,105 @@
|
||||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
||||
; RUN: opt -S -early-cse < %s | FileCheck %s
|
||||
|
||||
declare float @truncf(float) #0
|
||||
declare float @llvm.trunc.f32(float) #0
|
||||
declare double @trunc(double) #0
|
||||
declare double @llvm.trunc.f64(double) #0
|
||||
|
||||
define float @constant_fold_trunc_f32_01() #0 {
|
||||
; CHECK-LABEL: @constant_fold_trunc_f32_01(
|
||||
; CHECK-NEXT: ret float 1.000000e+00
|
||||
;
|
||||
%x = call float @truncf(float 1.25) #0
|
||||
ret float %x
|
||||
}
|
||||
|
||||
define float @constant_fold_trunc_f32_02() #0 {
|
||||
; CHECK-LABEL: @constant_fold_trunc_f32_02(
|
||||
; CHECK-NEXT: ret float -1.000000e+00
|
||||
;
|
||||
%x = call float @llvm.trunc.f32(float -1.25) #0
|
||||
ret float %x
|
||||
}
|
||||
|
||||
define float @constant_fold_trunc_f32_03() #0 {
|
||||
; CHECK-LABEL: @constant_fold_trunc_f32_03(
|
||||
; CHECK-NEXT: ret float 1.000000e+00
|
||||
;
|
||||
%x = call float @truncf(float 1.5) #0
|
||||
ret float %x
|
||||
}
|
||||
|
||||
define float @constant_fold_trunc_f32_04() #0 {
|
||||
; CHECK-LABEL: @constant_fold_trunc_f32_04(
|
||||
; CHECK-NEXT: ret float -1.000000e+00
|
||||
;
|
||||
%x = call float @llvm.trunc.f32(float -1.5) #0
|
||||
ret float %x
|
||||
}
|
||||
|
||||
define float @constant_fold_trunc_f32_05() #0 {
|
||||
; CHECK-LABEL: @constant_fold_trunc_f32_05(
|
||||
; CHECK-NEXT: ret float 2.000000e+00
|
||||
;
|
||||
%x = call float @truncf(float 2.75) #0
|
||||
ret float %x
|
||||
}
|
||||
|
||||
define float @constant_fold_trunc_f32_06() #0 {
|
||||
; CHECK-LABEL: @constant_fold_trunc_f32_06(
|
||||
; CHECK-NEXT: ret float -2.000000e+00
|
||||
;
|
||||
%x = call float @llvm.trunc.f32(float -2.75) #0
|
||||
ret float %x
|
||||
}
|
||||
|
||||
define double @constant_fold_trunc_f64_01() #0 {
|
||||
; CHECK-LABEL: @constant_fold_trunc_f64_01(
|
||||
; CHECK-NEXT: ret double 1.000000e+00
|
||||
;
|
||||
%x = call double @trunc(double 1.3) #0
|
||||
ret double %x
|
||||
}
|
||||
|
||||
define double @constant_fold_trunc_f64_02() #0 {
|
||||
; CHECK-LABEL: @constant_fold_trunc_f64_02(
|
||||
; CHECK-NEXT: ret double -1.000000e+00
|
||||
;
|
||||
%x = call double @llvm.trunc.f64(double -1.3) #0
|
||||
ret double %x
|
||||
}
|
||||
|
||||
define double @constant_fold_trunc_f64_03() #0 {
|
||||
; CHECK-LABEL: @constant_fold_trunc_f64_03(
|
||||
; CHECK-NEXT: ret double 1.000000e+00
|
||||
;
|
||||
%x = call double @trunc(double 1.5) #0
|
||||
ret double %x
|
||||
}
|
||||
|
||||
define double @constant_fold_trunc_f64_04() #0 {
|
||||
; CHECK-LABEL: @constant_fold_trunc_f64_04(
|
||||
; CHECK-NEXT: ret double -1.000000e+00
|
||||
;
|
||||
%x = call double @llvm.trunc.f64(double -1.5) #0
|
||||
ret double %x
|
||||
}
|
||||
|
||||
define double @constant_fold_trunc_f64_05() #0 {
|
||||
; CHECK-LABEL: @constant_fold_trunc_f64_05(
|
||||
; CHECK-NEXT: ret double 2.000000e+00
|
||||
;
|
||||
%x = call double @trunc(double 2.7) #0
|
||||
ret double %x
|
||||
}
|
||||
|
||||
define double @constant_fold_trunc_f64_06() #0 {
|
||||
; CHECK-LABEL: @constant_fold_trunc_f64_06(
|
||||
; CHECK-NEXT: ret double -2.000000e+00
|
||||
;
|
||||
%x = call double @llvm.trunc.f64(double -2.7) #0
|
||||
ret double %x
|
||||
}
|
||||
|
||||
attributes #0 = { nounwind readnone }
|
||||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
||||
; RUN: opt -S -early-cse < %s | FileCheck %s
|
||||
|
||||
declare float @truncf(float) #0
|
||||
declare float @llvm.trunc.f32(float) #0
|
||||
declare double @trunc(double) #0
|
||||
declare double @llvm.trunc.f64(double) #0
|
||||
|
||||
define float @constant_fold_trunc_f32_01() #0 {
|
||||
; CHECK-LABEL: @constant_fold_trunc_f32_01(
|
||||
; CHECK-NEXT: ret float 1.000000e+00
|
||||
;
|
||||
%x = call float @truncf(float 1.25) #0
|
||||
ret float %x
|
||||
}
|
||||
|
||||
define float @constant_fold_trunc_f32_02() #0 {
|
||||
; CHECK-LABEL: @constant_fold_trunc_f32_02(
|
||||
; CHECK-NEXT: ret float -1.000000e+00
|
||||
;
|
||||
%x = call float @llvm.trunc.f32(float -1.25) #0
|
||||
ret float %x
|
||||
}
|
||||
|
||||
define float @constant_fold_trunc_f32_03() #0 {
|
||||
; CHECK-LABEL: @constant_fold_trunc_f32_03(
|
||||
; CHECK-NEXT: ret float 1.000000e+00
|
||||
;
|
||||
%x = call float @truncf(float 1.5) #0
|
||||
ret float %x
|
||||
}
|
||||
|
||||
define float @constant_fold_trunc_f32_04() #0 {
|
||||
; CHECK-LABEL: @constant_fold_trunc_f32_04(
|
||||
; CHECK-NEXT: ret float -1.000000e+00
|
||||
;
|
||||
%x = call float @llvm.trunc.f32(float -1.5) #0
|
||||
ret float %x
|
||||
}
|
||||
|
||||
define float @constant_fold_trunc_f32_05() #0 {
|
||||
; CHECK-LABEL: @constant_fold_trunc_f32_05(
|
||||
; CHECK-NEXT: ret float 2.000000e+00
|
||||
;
|
||||
%x = call float @truncf(float 2.75) #0
|
||||
ret float %x
|
||||
}
|
||||
|
||||
define float @constant_fold_trunc_f32_06() #0 {
|
||||
; CHECK-LABEL: @constant_fold_trunc_f32_06(
|
||||
; CHECK-NEXT: ret float -2.000000e+00
|
||||
;
|
||||
%x = call float @llvm.trunc.f32(float -2.75) #0
|
||||
ret float %x
|
||||
}
|
||||
|
||||
define double @constant_fold_trunc_f64_01() #0 {
|
||||
; CHECK-LABEL: @constant_fold_trunc_f64_01(
|
||||
; CHECK-NEXT: ret double 1.000000e+00
|
||||
;
|
||||
%x = call double @trunc(double 1.3) #0
|
||||
ret double %x
|
||||
}
|
||||
|
||||
define double @constant_fold_trunc_f64_02() #0 {
|
||||
; CHECK-LABEL: @constant_fold_trunc_f64_02(
|
||||
; CHECK-NEXT: ret double -1.000000e+00
|
||||
;
|
||||
%x = call double @llvm.trunc.f64(double -1.3) #0
|
||||
ret double %x
|
||||
}
|
||||
|
||||
define double @constant_fold_trunc_f64_03() #0 {
|
||||
; CHECK-LABEL: @constant_fold_trunc_f64_03(
|
||||
; CHECK-NEXT: ret double 1.000000e+00
|
||||
;
|
||||
%x = call double @trunc(double 1.5) #0
|
||||
ret double %x
|
||||
}
|
||||
|
||||
define double @constant_fold_trunc_f64_04() #0 {
|
||||
; CHECK-LABEL: @constant_fold_trunc_f64_04(
|
||||
; CHECK-NEXT: ret double -1.000000e+00
|
||||
;
|
||||
%x = call double @llvm.trunc.f64(double -1.5) #0
|
||||
ret double %x
|
||||
}
|
||||
|
||||
define double @constant_fold_trunc_f64_05() #0 {
|
||||
; CHECK-LABEL: @constant_fold_trunc_f64_05(
|
||||
; CHECK-NEXT: ret double 2.000000e+00
|
||||
;
|
||||
%x = call double @trunc(double 2.7) #0
|
||||
ret double %x
|
||||
}
|
||||
|
||||
define double @constant_fold_trunc_f64_06() #0 {
|
||||
; CHECK-LABEL: @constant_fold_trunc_f64_06(
|
||||
; CHECK-NEXT: ret double -2.000000e+00
|
||||
;
|
||||
%x = call double @llvm.trunc.f64(double -2.7) #0
|
||||
ret double %x
|
||||
}
|
||||
|
||||
attributes #0 = { nounwind readnone }
|
@ -1,4 +1,4 @@
|
||||
; RUN: opt -constprop < %s
|
||||
; RUN: opt -instsimplify < %s
|
||||
|
||||
; Make sure we don't crash on this one
|
||||
|
@ -1,5 +1,5 @@
|
||||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
||||
; RUN: opt < %s -constprop -S | FileCheck %s
|
||||
; RUN: opt < %s -instsimplify -S | FileCheck %s
|
||||
|
||||
declare i32 @llvm.experimental.vector.reduce.add.v1i32(<1 x i32> %a)
|
||||
declare i32 @llvm.experimental.vector.reduce.add.v8i32(<8 x i32> %a)
|
@ -1,5 +1,5 @@
|
||||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
||||
; RUN: opt < %s -constprop -S -o - | FileCheck %s
|
||||
; RUN: opt < %s -instsimplify -S -o - | FileCheck %s
|
||||
|
||||
; When both operands are undef in a lane, that lane should produce an undef result.
|
||||
|
@ -1,32 +1,32 @@
|
||||
; RUN: opt -early-cse -S < %s | FileCheck %s
|
||||
|
||||
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
|
||||
target triple = "aarch64"
|
||||
|
||||
; CHECK-LABEL: define <4 x i32*> @fixed_length_version_first() {
|
||||
; CHECK-NEXT: ret <4 x i32*> undef
|
||||
define <4 x i32*> @fixed_length_version_first() {
|
||||
%ptr = getelementptr i32, <4 x i32*> undef, <4 x i64> undef
|
||||
ret <4 x i32*> %ptr
|
||||
}
|
||||
|
||||
; CHECK-LABEL: define <4 x <4 x i32>*> @fixed_length_version_second() {
|
||||
; CHECK-NEXT: ret <4 x <4 x i32>*> undef
|
||||
define <4 x <4 x i32>*> @fixed_length_version_second() {
|
||||
%ptr = getelementptr <4 x i32>, <4 x i32>* undef, <4 x i64> undef
|
||||
ret <4 x <4 x i32>*> %ptr
|
||||
}
|
||||
|
||||
; CHECK-LABEL: define <vscale x 4 x i32*> @vscale_version_first() {
|
||||
; CHECK-NEXT: ret <vscale x 4 x i32*> undef
|
||||
define <vscale x 4 x i32*> @vscale_version_first() {
|
||||
%ptr = getelementptr i32, <vscale x 4 x i32*> undef, <vscale x 4 x i64> undef
|
||||
ret <vscale x 4 x i32*> %ptr
|
||||
}
|
||||
|
||||
; CHECK-LABEL: define <vscale x 4 x <vscale x 4 x i32>*> @vscale_version_second() {
|
||||
; CHECK-NEXT: ret <vscale x 4 x <vscale x 4 x i32>*> undef
|
||||
define <vscale x 4 x <vscale x 4 x i32>*> @vscale_version_second() {
|
||||
%ptr = getelementptr <vscale x 4 x i32>, <vscale x 4 x i32>* undef, <vscale x 4 x i64> undef
|
||||
ret <vscale x 4 x <vscale x 4 x i32>*> %ptr
|
||||
}
|
||||
; RUN: opt -early-cse -S < %s | FileCheck %s
|
||||
|
||||
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
|
||||
target triple = "aarch64"
|
||||
|
||||
; CHECK-LABEL: define <4 x i32*> @fixed_length_version_first() {
|
||||
; CHECK-NEXT: ret <4 x i32*> undef
|
||||
define <4 x i32*> @fixed_length_version_first() {
|
||||
%ptr = getelementptr i32, <4 x i32*> undef, <4 x i64> undef
|
||||
ret <4 x i32*> %ptr
|
||||
}
|
||||
|
||||
; CHECK-LABEL: define <4 x <4 x i32>*> @fixed_length_version_second() {
|
||||
; CHECK-NEXT: ret <4 x <4 x i32>*> undef
|
||||
define <4 x <4 x i32>*> @fixed_length_version_second() {
|
||||
%ptr = getelementptr <4 x i32>, <4 x i32>* undef, <4 x i64> undef
|
||||
ret <4 x <4 x i32>*> %ptr
|
||||
}
|
||||
|
||||
; CHECK-LABEL: define <vscale x 4 x i32*> @vscale_version_first() {
|
||||
; CHECK-NEXT: ret <vscale x 4 x i32*> undef
|
||||
define <vscale x 4 x i32*> @vscale_version_first() {
|
||||
%ptr = getelementptr i32, <vscale x 4 x i32*> undef, <vscale x 4 x i64> undef
|
||||
ret <vscale x 4 x i32*> %ptr
|
||||
}
|
||||
|
||||
; CHECK-LABEL: define <vscale x 4 x <vscale x 4 x i32>*> @vscale_version_second() {
|
||||
; CHECK-NEXT: ret <vscale x 4 x <vscale x 4 x i32>*> undef
|
||||
define <vscale x 4 x <vscale x 4 x i32>*> @vscale_version_second() {
|
||||
%ptr = getelementptr <vscale x 4 x i32>, <vscale x 4 x i32>* undef, <vscale x 4 x i64> undef
|
||||
ret <vscale x 4 x <vscale x 4 x i32>*> %ptr
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
||||
; RUN: opt < %s -constprop -S -verify | FileCheck %s
|
||||
; RUN: opt < %s -instsimplify -S -verify | FileCheck %s
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Unary Operations
|
||||
@ -225,14 +225,14 @@ define <vscale x 4 x i32> @select() {
|
||||
ret <vscale x 4 x i32> %r
|
||||
}
|
||||
|
||||
declare <vscale x 16 x i8> @llvm.sadd.sat.nxv16i8(<vscale x 16 x i8>, <vscale x 16 x i8>)
|
||||
declare <vscale x 16 x i8> @llvm.something(<vscale x 16 x i8>, <vscale x 16 x i8>)
|
||||
|
||||
define <vscale x 16 x i8> @call() {
|
||||
; CHECK-LABEL: @call(
|
||||
; CHECK-NEXT: [[R:%.*]] = call <vscale x 16 x i8> @llvm.sadd.sat.nxv16i8(<vscale x 16 x i8> undef, <vscale x 16 x i8> undef)
|
||||
; CHECK-NEXT: [[R:%.*]] = call <vscale x 16 x i8> @llvm.something(<vscale x 16 x i8> undef, <vscale x 16 x i8> undef)
|
||||
; CHECK-NEXT: ret <vscale x 16 x i8> [[R]]
|
||||
;
|
||||
%r = call <vscale x 16 x i8> @llvm.sadd.sat.nxv16i8(<vscale x 16 x i8> undef, <vscale x 16 x i8> undef)
|
||||
%r = call <vscale x 16 x i8> @llvm.something(<vscale x 16 x i8> undef, <vscale x 16 x i8> undef)
|
||||
ret <vscale x 16 x i8> %r
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
; Make sure this doesn't turn into an infinite loop
|
||||
|
||||
; RUN: opt < %s -simplifycfg -constprop -simplifycfg | llvm-dis | FileCheck %s
|
||||
; RUN: opt < %s -simplifycfg -instsimplify -simplifycfg | llvm-dis | FileCheck %s
|
||||
|
||||
%struct.anon = type { i32, i32, i32, i32, [1024 x i8] }
|
||||
@_zero_ = external global %struct.anon* ; <%struct.anon**> [#uses=2]
|
||||
|
@ -285,7 +285,6 @@ protected:
|
||||
|
||||
void buildAndRunPasses() {
|
||||
LLVMPassManagerRef pass = LLVMCreatePassManager();
|
||||
LLVMAddConstantPropagationPass(pass);
|
||||
LLVMAddInstructionCombiningPass(pass);
|
||||
LLVMRunPassManager(pass, Module);
|
||||
LLVMDisposePassManager(pass);
|
||||
|
@ -15,7 +15,6 @@ static_library("Scalar") {
|
||||
"BDCE.cpp",
|
||||
"CallSiteSplitting.cpp",
|
||||
"ConstantHoisting.cpp",
|
||||
"ConstantProp.cpp",
|
||||
"CorrelatedValuePropagation.cpp",
|
||||
"DCE.cpp",
|
||||
"DeadStoreElimination.cpp",
|
||||
|
Loading…
x
Reference in New Issue
Block a user